Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJohn Sinclair
247 PointsSQL Query Fix
Hi All
Can you advise what wrong with my SQL query
Getting this error
ORA-00936: missing expression
00000 - "missing expression" Cause: *Action: Error at Line: 2 Column: 24 SELECT FROM DATA_NETWORK_AUDIT WHERE (nominated_party like '%Kier Group PLC%' or nominated_party like '%Kier%' or nominated_party like '%C&W Kier%' or SELECT LOWER('keir') from DATA_NETWORK_AUDIT;)
2 Answers
Steven Parker
231,269 PointsThere seem to be a few issues:
- there should be something being selected between the first SELECT and FROM
- the parentheses seem misplaced (and perhaps not needed)
- the purpose of the second "SELECT" is not clear, perhaps it's also not needed
-
LOWER('keir')
would be the same thing as just'keir'
, did you want a field reference?
Also, while it won't cause an error, it is not necessary to separately test for "like '%Kier Group PLC%'
" or "like '%C&W Kier%'
" because "like '%Kier%'
" would cover both of those patterns by itself.
John Sinclair
247 PointsHi Steven
So I need to pull information from our backend SQL table
The name is Kier but there so many variables of the name
I was told to use lower in my query to get results regardless of the variables of the name
Thanks
John Sinclair
247 PointsJohn Sinclair
247 PointsCan suggest how it should look
Steven Parker
231,269 PointsSteven Parker
231,269 PointsI'd need to know more about what the query is intended to do, it's not clear from this code.
Steven Parker
231,269 PointsSteven Parker
231,269 PointsSo if you want all fields from each row and do a case-insensitive match on the name, you might use:
SELECT * FROM DATA_NETWORK_AUDIT WHERE LOWER(nominated_party) like '%kier%';
The "
*
" symbol is a shorthand that means "all columns".