Skip to content
Advertisement

How to join two tables in sql according to a determined value?

I have the following tables and I have to get all orders of customer Meier.

Table Customer with columns cid and name:

Table Orders with columns Oid, Did, Date and Cid:

What I have tried is the following:

But there is a syntax error that I am not able to find. How should I proceed in this case?

enter image description here

Advertisement

Answer

The best way is to use aliases. So your select statement should look like this(I will use alias o for Orders and c for Customer):

If you would like to solve the problem without aliases (which I don’t prefer), you should do this:

So table name before table attribute. And be careful around the quotes… ” and ‘ have different meaning… It also leads in errors. Please read this post What is the difference between single and double quotes in SQL?

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement