 |
แก้ไขโค๊ดให้หน่อยครับ พอดีซ้อนตารางไม่ถูกต้อง |
|
 |
|
|
 |
 |
|
ทำอย่างไรให้ตรง id_con ของ contact_tel = id_con ของ contact
id_con = id_con
พอดีมัน error ตรงนี้ครับ จะแก้เขียนให้ถูกย่างไรครับ
Code (PHP)
$strSQL = "select d.ThaiName AS ThaiName,d.EngName, (select top 1 tel from tel where id_detail = d.id_detail) AS tel,(select top 1 fax from fax where id_detail = d.id_detail) AS fax,(select con_name from contact where id_detail = d.id_detail) AS con_name ,(select c_name from contact where id_detail = d.id_detail) AS c_name,(select c_lastname from contact where id_detail = d.id_detail) AS c_lastname,(select c_tel from contact_tel where id_con = id_con) AS c_tel from detail d WHERE Enable='T' AND IsActive='T' ";
Warning: mssql_query() [function.mssql-query]: message: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. (severity 16) in
Tag : PHP, Ms SQL Server 2008
|
|
 |
 |
 |
 |
Date :
2011-08-17 15:29:26 |
By :
MyZeus |
View :
1074 |
Reply :
8 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอขุดหน่อยนะครับ ยังแก้ไม่ได้เลย
|
 |
 |
 |
 |
Date :
2011-08-17 20:08:58 |
By :
MyZeus |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แนะ นำ ครับ ให้
Code (PHP)
echo $strSQL;
เดียวก็ รู้ ครับ
|
 |
 |
 |
 |
Date :
2011-08-17 20:43:51 |
By :
Professer |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Warning: mssql_query() [function.mssql-query]: Query failed in C:\AppServ\www\CC\test.php on line 17
Error Query [select d.ThaiName AS ThaiName,d.EngName,d.id_detail,d.word,d.type,d.orther,d.Address,d.province,d.amphur,d.district,d.zip,d.mail,d.web,d.hotline,d.busi,d.bg,d.service,d.etc,d.detail,d.price,d.branch,d.commonday,d.holiday,d.note,d.town1,d.town2,d.town3,d.town4,d.rate,d.Created,d.CreatedBy,d.CreatedTime,d.Updated,d.UpdatedBy,d.UpdatedTime,d.IsSecret,d.IsActive,d.Enable,d.Deleted,d.DeletedBy,d.DeletedTime, (select top 1 tel from tel where id_detail = d.id_detail) AS tel,(select top 1 fax from fax where id_detail = d.id_detail) AS fax,(select con_name from contact where id_detail = d.id_detail) AS con_name ,(select c_name from contact where id_detail = d.id_detail) AS c_name,(select c_lastname from contact where id_detail = d.id_detail) AS c_lastname,(select c_add from contact where id_detail = d.id_detail) AS c_add,(select c_province from contact where id_detail = d.id_detail) AS c_province ,(select c_amphur from contact where id_detail = d.id_detail) AS c_amphur,(select c_district from contact where id_detail = d.id_detail) AS c_district,(select c_zip from contact where id_detail = d.id_detail) AS c_zip ,(select c_tel from contact_tel where id_con = id_con) AS c_tel from detail d WHERE Enable='T' AND IsActive='T' ]
ถึง echo ออกมา ก็ไม่น่าจะเห็นอะไรหรอกครับ ที่ผิดมันอยู่ตรงที่
(select c_tel from contact_tel where id_con = id_con) id_con=id_con มันไม่ถูกต้องครับ แต่ไม่รู้จะแก้ให้ถูกต้องยังไงเท่านั้นเอง
|
 |
 |
 |
 |
Date :
2011-08-17 20:48:14 |
By :
MyZeus |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช้ SUB SELECT แบบนี้ไม่ค่อยดีน่ะครับ มันทำงานช้ากว่าการ JOIN ครับ
|
 |
 |
 |
 |
Date :
2011-08-17 20:54:27 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมจนปัญญาจริงๆครับ เพราะ 1 ธุรกิจมีได้หลายเบอร์ แต่ผมต้องการให้โชว์แค่เบอร์เดียวเท่านั้น เลยต้องทำแบบนี้ครับ ผมว่าผลลัพธ์ในการใช้ฐานข้อมูลระหว่าง mysql กับ sql server 2008 ต่างกันครับ(ความคิดเห็นส่วนตัว) เพราะผมก็ลองทำตาม distinct บ้าง group by บ้าง ก็ไม่ออก สรุปเลยตอนนี้มีวิธีแก้ encode ของผมไหมคับ
|
 |
 |
 |
 |
Date :
2011-08-17 21:31:41 |
By :
MyZeus |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พอแก้ได้ไหมคับ
|
 |
 |
 |
 |
Date :
2011-08-18 07:15:22 |
By :
MyZeus |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Limitเบอโทรสิ
|
 |
 |
 |
 |
Date :
2011-08-18 09:51:37 |
By :
sambrazil |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
limit ไม่สามารถใช้กับ sql server ได้ครับ
|
 |
 |
 |
 |
Date :
2011-08-18 09:59:31 |
By :
MyZeus |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|