Home > database >  Mysql nested query
Mysql nested query

Time:09-23

SELECT * FROM [dbo] [Product]
WHERE [CategoryID] IN (
SELECT [CategoryID] FROM [dbo] [Category] WHERE [CategoryID] <=10
)

This did not understand, feel and

SELECT * FROM [dbo] [Product]
WHERE [CategoryID] WHERE [CategoryID] <=10

Is the same as

CodePudding user response:

2 table Product and Category, these two tables have a CategoryID field, if the two table this field & lt;=10 as is the same, the value of the
But if the Product. The CategoryID value is 1, 2, 3, 4, 5, the Category, CategoryID value only 1, 2, 3, it won't be the same,

CodePudding user response:

Is not a table, and the contents of this field two tables are not necessarily the same

CodePudding user response:

Left the join is better,?

CodePudding user response:

On the second floor is the key, usually is the same, do not rule out is different when you data inconsistency
  • Related