MySQL查询检查

时间:2010-08-12 12:37:19

标签: mysql

此查询有什么问题?

INSERT INTO table1 VALUES id, pic0, pic1, pic2, pic3, pic4 FROM table2 WHERE condition1 = 'cond1' AND condition2 = 'cond2' AND age = '18' AND ( weight = '100 - 115 lbs' OR weight = '115- 130 lbs' ) AND hairlength <> 'short'

条件适用于table2。 我想在表1中插入表2中的行,这些行符合在WHERE子句之后设置我的条件。

谢谢你

2 个答案:

答案 0 :(得分:2)

我想你想要:

INSERT INTO table1 (id, pic0, pic1, pic2, pic3, pic4)
SELECT id, pic0, pic1, pic2, pic3, pic4
FROM table2
WHERE condition1 = 'cond1' 
AND condition2 = 'cond2' AND age = '18' 
AND ( weight = '100 - 115 lbs' OR weight = '115- 130 lbs' )
AND hairlength <> 'short'

答案 1 :(得分:0)

试试这个 -

INSERT INTO table1 (id, pic0, pic1, pic2, pic3, pic4)
select id, pic0, pic1, pic2, pic3, pic4  
FROM table2 WHERE condition1 = 'cond1' AND condition2 = 'cond2' 
AND age = '18' AND ( weight = '100 - 115 lbs' OR weight = '115- 130 lbs' ) 
AND hairlength <> 'short'