具有多个帐号的SQL WHERE语句

时间:2015-05-11 14:38:06

标签: sql sql-server boolean where

我正在使用SQL查询,我需要显示一组信息,但我有5条记录要显示。以下查询无效:

SELECT m.customer_number, m.last_name, m.billing_address_line_1, m.billing_address_line_2, m.billing_city, m.billing_state, m.phone_number1, c.equipment_serial_no, c.make, c.model_number, c.color_code 
FROM customer_master as m
INNER JOIN equip_master as c ON m.customer_number = c.customer_number
WHERE m.customer_number = '19975107' AND '1039283' AND '39203821' AND '23824917' AND '1833729'

我收到以下错误:

  

Msg 4145,Level 15,State 1,Line 9非布尔类型的表达式   在预期条件的上下文中指定,接近' 19978107'

1 个答案:

答案 0 :(得分:6)

这不是一个有效的语法。如果您想获取customer_number列表,请使用IN子句。

....
WHERE m.customer_number in('19975107', '1039283', '39203821' 
                           ,'23824917' , '1833729')