สอบถามวีธีดึงค่าจาก table mySQL ครับ

เริ่มโดย smapan, 10 เมษายน 2010, 08:49:39

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

smapan

ผมมี table อยู่ 2 เทเบิ้ล คือ  tblLists,tblMoreinfo
tblLists เก็บค่า บ้านเลขที่,อำเภอ,จังหวัด,รหัสไปรษณีย์
tblMoreinfo เก็บค่า ชื่อฟิล์ตำบล,ค่าของฟิลตำบล,ชื่อฟิล์ถนน และ ค่าของฟิลถนน
ค่าฟิล id คือ index
list_id คือ ตัวที่ลิ้งกันระหว่าง 2 เทเบิ้ลครับ

tblLists
====================
id = 1
list_id = 1
address = "651/44 หมู1"
aumpher = "บ้านโป่ง"
province = "ราชบุรี"
postcode = "70100"
id = 2
list_id = 2
address = "32/4 ซอย4"
aumpher = "เมืองนครนายก"
province = "นครนายก"
postcode = "40100"

tblMoreinfo
====================
id = 1
list_id = 1
attb = "tumbon"
value = "ห้วยแป้ง"

id = 2
list_id = 1
attb = "road"
value = "ถนนแสงชูโต"

id = 3
list_id = 2
attb = "tumbon"
value = "ห้วยทับ"

id = 4
list_id = 2
attb = "road"
value = "ถนนอมรศรี"


ผมอยากทราบว่า ถ้าจะดึงข้อมูล ทั้งหมด ทุกค้ามารวมเปน เทเบิ้ลเดียวกัน ให้ผลออกมาเปนแบบนี้ ทำไงครับ
**ค่าในฟิลของเทเบิ้ล 2 จะเปนชื่อฟิล์ของผลรวมครับ
tblAll
===================
list_id = 1
address = "651/44 หมู1"
tumbon = "ห้วยแป้ง"
road = "ถนนแสงชูโต"
aumpher = "บ้านโป่ง"
province = "ราชบุรี"
postcode = "70100"

id = 2
list_id = 2
address = "32/4 ซอย4"
tumbon = "ห้วยทับ"
road = "ถนนอมรศรี"
aumpher = "เมืองนครนายก"
province = "นครนายก"
postcode = "40100"

ขอบคุณครับ.

[direct=http://cp.siamhostweb.com/cart.php?gid=1]จูมล่าโฮส สยามโฮสเว็บ[/direct] [direct=http://www.modty.com]modty.com[/direct]
[direct=http://www.apartment.in.th]รวมที่พัก เช่ารายวัน ที่พักเช่ารายเดือนมากที่สุดแจ่มจริง[/direct]
***Tel 083-757-1515 ติดปัญหา Joomla ตรงไหนรับปรึกษาฟรี โทรมาเถอะครับ ถ้าตอบได้ช่วยแน่นอน ไม่มีกั้ก. ***

iPokz

█ รับติดตั้งปรับแต่ง VPS/Server ค่าบริการเริ่มต้นครั้งละ 500 บาท
█ รับวางเครื่อง Colocation พร้อมปรับแต่งการใช้งานราคามิตรภาพ
█ [direct=http://www.suksonhost.com/seo-hosting]SEO Hosting 25IPs[/direct] ราคาเริ่มต้น 250 บาทเลือกไอพีใช้งานได้เอง
█ Contact : 084-0613164 (Pok)
= = =
█ เป้าหมาย : ขอกำไรแค่เดือนละหมื่นให้แม่พ่อไม่ต้องทำงาน

itportal

select tblLists.*, tblMoreinfo.* from tblLists, tblMoreinfo where tblLists.list_id = tblMoreinfo.list_id
[direct=http://phuketecho.blogspot.com/]ภูเก็ต[/direct] | [direct=http://www.phuketoriginalseafood.com]Phuket Seafood Restaurant[/direct] | [direct=http://www.phuketecho.com]Phuket classifieds[/direct]

smapan

อ้างถึงจาก: itportal ใน 10 เมษายน 2010, 10:20:14
select tblLists.*, tblMoreinfo.* from tblLists, tblMoreinfo where tblLists.list_id = tblMoreinfo.list_id

ขอบคุณครับ
+1
[direct=http://cp.siamhostweb.com/cart.php?gid=1]จูมล่าโฮส สยามโฮสเว็บ[/direct] [direct=http://www.modty.com]modty.com[/direct]
[direct=http://www.apartment.in.th]รวมที่พัก เช่ารายวัน ที่พักเช่ารายเดือนมากที่สุดแจ่มจริง[/direct]
***Tel 083-757-1515 ติดปัญหา Joomla ตรงไหนรับปรึกษาฟรี โทรมาเถอะครับ ถ้าตอบได้ช่วยแน่นอน ไม่มีกั้ก. ***