จะsearchหาข้อมูลแต่ใช้ 2 keywordทำยังไงคะ

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: จะsearchหาข้อมูลแต่ใช้ 2 keywordทำยังไงคะ

Re: จะsearchหาข้อมูลแต่ใช้ 2 keywordทำยังไงคะ

โดย aei_ou » 24/02/2009 2:49 pm

ลองดูคำสั่ง SQL จากตัวอย่างนี้นะ

SELECT employees.*, departments.deptname
FROM employees, departments
WHERE employees.deptid = departments.deptid
AND ( employees.employeeid LIKE '%colname%'
AND employees.firstname LIKE '%colname%'
AND employees.lastname LIKE '%colname%'
AND employees.email LIKE '%colname%'
AND departments.deptname LIKE '%colname%'
)
ORDER BY firstname ASC

จะsearchหาข้อมูลแต่ใช้ 2 keywordทำยังไงคะ

โดย Lekzaza » 18/02/2009 1:30 pm

คือสมมุตเราจะ search ว่า ชื่อ อรุณทิพ อยู่ จังหวัดไหน และ ตำบล ไรประมานนี้อะคะ
เราก้พิมพ์ อรุณทิพ แล้วเลือก field จังหวัด และ อีกอันเราเลือก field ตำบล
แล้วเครื่องจะคำนวนว่า มีคนชื่อ อรุณทิพ อยู่จังหวัดไหนและตำบลไร อะคะ
ประมานนี้อะคะ
ช่วยด้วยนะคะ งง อยู่คะ หรือว่า เราจะทำการ if else ละคะ

ข้างบน