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 trial

General Discussion

SQL Query

Hi All

Can you advise what wrong with my SQL query

Getting this error

ORA-00936: missing expression

  1. 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

Can 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?

8 Answers

This is a query for work which am trying obtain data

The customer name various and in some cases it could be in lower case

If anyone can help me fix this query then that would be great

On 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.

Hi Kris

So how do I fix it

What change do I need to make to get it to work

The 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.

I 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

Thank you

So I can add different names