$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
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 มันไม่ถูกต้องครับ แต่ไม่รู้จะแก้ให้ถูกต้องยังไงเท่านั้นเอง