Skip to content
Advertisement

A problem with SQL when selecting data from two tables

i need to have this result

from this tables (examples):

1) customers sort by id

2) orders sort by order_num

I need to have the result, where 500<=amount<=2000 selecting order_num , amount , name

thats my code but it doesnt work

it gets

Advertisement

Answer

Your query returns the cartesian product of the 2 tables because this:

is a CROSS JOIN.
What you should do is an INNER JOIN with an ON clause so every row of orders is associated to the proper row of customers:

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