 |
ถามเรื่องการ select ใน sql หน่อยครับ select * from tb where **userid=12,23,45,56,78 **<<เลือกเรคคอดตามไอดีที่กำหนด |
|
 |
|
|
 |
 |
|
select * from tb where userid in (12,23,45,56,78)
ลองใช้ IN ดูครับ
|
 |
 |
 |
 |
Date :
2011-05-23 11:46:20 |
By :
ไวยวิทย์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$strUid = "12,23,45,56,78 ";
$strSQL = "select * from tb where userid in ('".str_repalce(",","','",$strUid)."') ";
มันจะได้เป็น
Code
select * from tb where userid in ('12','23','45','56','78')
|
 |
 |
 |
 |
Date :
2011-05-23 11:47:15 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|