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
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;)
Thanks
John
8 Answers
John Sinclair
247 PointsThis is a query for work which am trying obtain data
The customer name various and in some cases it could be in lower case
John Sinclair
247 PointsIf anyone can help me fix this query then that would be great
KRIS NIKOLAISEN
54,971 PointsOn its own 'SELECT LOWER('keir') from DATA_NETWORK_AUDIT' will create a new column of results with the literal string 'keir' so I don't think that is what you want. The nominated_party like '%Kier%'
condition includes both upper and lowercase matches that contain Kier (at least with SQLite - the db used in SQL playground here). This condition also makes '%Kier Group PLC%' and '%C&W Kier%' redundant.
John Sinclair
247 PointsHi Kris
So how do I fix it
John Sinclair
247 PointsWhat change do I need to make to get it to work
KRIS NIKOLAISEN
54,971 PointsThe following will select variations of Kier both uppercase and lowercase at least with SQLite in the SQL playground:
SELECT * FROM DATA_NETWORK_AUDIT WHERE (nominated_party like 'Kier %' or nominated_party like '% Kier %' or nominated_party like '% Kier' or nominated_party like 'kier')
This would exclude names like Kieran.
KRIS NIKOLAISEN
54,971 PointsI read your other post and from that would update my query to:
SELECT * FROM DATA_NETWORK_AUDIT WHERE (
LOWER(nominated_party) like 'kier %' or
LOWER(nominated_party) like '% kier %' or
LOWER(nominated_party) like '% kier' or
LOWER(nominated_party) = 'kier')
This is one way to deal with case sensitivity
John Sinclair
247 PointsThank you
So I can add different names
KRIS NIKOLAISEN
54,971 PointsKRIS NIKOLAISEN
54,971 PointsCan you provide a link to the course or explain why you want to use 'SELECT LOWER('keir') from DATA_NETWORK_AUDIT' in a WHERE clause?