我想请一位对INNER JOIN
有良好经验的人提供帮助。这里我有两张桌子
Table 1
===========
id | name
===========
1 | john
2 | mark
Table 2
======================================
id | customer_id | like_to_eat
======================================
1 | 1 | cake
2 | 2 | cake
3 | 1 | pudding
4 | 1 | chocolate
我想查询找出哪些顾客想吃“蛋糕”
我已经完成了这个
SELECT *
FROM table1
INNER JOIN table2
ON table1.id = table2.customer_id
WHERE table2.like_to_eat ='cake'
但是我再次得到正确的$row['id']
任何帮助表示感谢。
答案 0 :(得分:1)
基于评论
SELECT table1.id as TheIDIReallyNeed
, table1.name
, table2.id
, table2.customer_id
, table2.like_to_eat
FROM table1
INNER JOIN table2
ON table1.id = table2.customer_id
WHERE table2.like_to_eat ='cake'