我不能寫一個SQL查詢,我需要連接兩個表並獲得兩者的公共值。加入在哪裏,幷包含子句
這樣的事情,
select control_id from ProjectImage
where group_id ="20"
Join
(select images from coupon where coupon_name is "test" and images contains control_id of projectImage)
圖像是contol_id的用逗號分隔開的列表。
所以最後我只想要那些存在於優惠券的表格圖像列中的control ids
。
ProjectImage table ----
image_id bigint(20)
control_id varchar(255)
name varchar(255)
project_id bigint(20)
group_id bigint(20)
Coupon table:
id bigint(20)
image varchar(1250)
name varchar(255)
status int(11)
wafer_id bigint(20)
選擇字段從表1上其中加入表2中的結構 https://dev.mysql.com/doc/refman/5.0/en/join.html –
Akhil
首先,它是MySql還是Sql Server?其次,連接應該在where子句之前 –
[MySQL連接where子句]的可能重複(http://stackoverflow.com/questions/1219909/mysql-join-with-where-clause) – Akhil