SQL variables with spaces in them?
My existing dataflow has column names like "trade show", "contact person" and so on. But when I write SQL code for the transform, I get syntax errors:
SELECT TOP 10 trade show,contact person from my_data_flow
SELECT TOP 10 [trade show],[contact person] from my_data_flow
none of these work. What should the query look like? Apologies from a "newbie" - Thank you all!
Best Answer
-
Looks like you might have the Redshift version of Dataflow. Is that right?
Redshift uses double quotes to do the same thing.
select
"business email"
from
datasetAaron
MajorDomo @ Merit Medical
**Say "Thanks" by clicking the heart in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0
Answers
-
For MySQL use the backtick character ` (not apostrophe- that creates a string) surrounding your column names.
ie
SELECT
`trade show`
,`contact person`
FROM
my_data_flowThat should also turn the name of your column light blue so you can tell that it worked.
Aaron
MajorDomo @ Merit Medical
**Say "Thanks" by clicking the heart in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"3 -
-
Looks like you might have the Redshift version of Dataflow. Is that right?
Redshift uses double quotes to do the same thing.
select
"business email"
from
datasetAaron
MajorDomo @ Merit Medical
**Say "Thanks" by clicking the heart in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0 -
THAT WAS IT - many thanks - I owe you a million bucks
0 -
Lol. Small, unmarked bills, por favor.
Keep in mind you'll need to use the same syntax when referencing spaced column names anywhere in your query, including the FROM and WHERE clauses.
SELECT
a."Customer Name"
,b."trx amount"
FROM
customers a
JOIN transactions b
ON a."customer id" = b."customer id"http://docs.aws.amazon.com/redshift/latest/dg/cm_chap_SQLCommandRef.html
Aaron
MajorDomo @ Merit Medical
**Say "Thanks" by clicking the heart in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0 -
Got it, thank you. Could I bother you with another question? I'm choosing the column names from the existing dataflow, and I understand if a column name I need isn't in it, I can add in another dataflow. But is there a quick way of finding the column names in ALL the dataflows, without having to open every one and examine the list? Thank you
0 -
You can add columns from other datets by joining them as another dataset to the dataflow you're working on. There isn't an easy way to search all columns of all datasets (a good idea), but you can hover over the 'Rows/Columns' section in the list of datasets in of the Datacenter, which will display all of the column names for a particular dataset. That way you can quickly view the contents of every dataset instead of opening and previewing each individually.
Aaron
MajorDomo @ Merit Medical
**Say "Thanks" by clicking the heart in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0 -
Thank you Aaron, that's very helpful. I owe you lunch if you're ever in the Santa Barbara area.
1 -
Haha! Deal.
Aaron
MajorDomo @ Merit Medical
**Say "Thanks" by clicking the heart in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"1 -
Hi Guys,
I am having similar issues when trying to put together an SQL query against an import excel file, where there is a space in the column name.
If I just do;
SELECT *
FROM Data_set
The Data displays fine, but when I try to just select a column that happens to have a space in the name, it just repeats the column name in the result,
SELECT 'Date Due'
FROM Data_set
for example. Screenshot attached. Any ideas?
0 -
If you are using a MySQL Dataflow, you have to use the backtick, not the single or double quote:
SELECT `Date Due` -- not 'Date Due' or "Date Due"
FROM Data_set
1
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive