我不能写一个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