[code=php] $sql_ary = array(
'SELECT' => 'tp.*,t.forum_id, t.topic_title, t.topic_poster, t.topic_time, t.topic_first_poster_name',
'FROM' => array(
'phpbb_m_topic_portal' => 'tp',
),
'LEFT_JOIN' => array(
array(
'FROM' => array(TOPICS_TABLE => 't'),
'ON' => 'tp.topic_id=t.topic_id',
),
),
'LEFT_JOIN' => array(
array(
'FROM' => array(USERS_TABLE => 'u'),
'ON' => 'u.user_id=tp.add_by',
),
),
'WHERE' => "forum_id = ". $db->sql_escape(utf8_clean_string($search))." OR topic_title LIKE '%"
.$db->sql_escape(utf8_clean_string($search))."%'OR topic_poster LIKE '%"
.$db->sql_escape(utf8_clean_string($search))."%' OR topic_time LIKE '%"
.$db->sql_escape(utf8_clean_string($search))."%' OR topic_first_poster_name LIKE '%"
.$db->sql_escape(utf8_clean_string($search))."%' OR username LIKE '%"
.$db->sql_escape(utf8_clean_string($search))."%' ",
'ODER BY' => 'tp.potal_order DESC',
);
$sql = $db->sql_build_query('SELECT', $sql_ary);
echo $sql; exit;
[/code]
SELECT tp.*,t.forum_id, t.topic_title, t.topic_poster, t.topic_time, t.topic_first_poster_name
FROM (phpbb_m_topic_portal tp) LEFT
JOIN phpbb_users u ON (u.user_id=tp.add_by)
WHERE forum_id = d
OR topic_title LIKE '%d%'
OR topic_poster LIKE '%d%'
OR topic_time LIKE '%d%'
OR topic_first_poster_name LIKE '%d%'
OR username LIKE '%d%'
"LEFT_JOIN" 2 ตารางใน phpBB จะทำยังไงค่ะ
Moderator: mindphp, ผู้ดูแลกระดาน
- thatsawan
- PHP VIP Members
- โพสต์: 28508
- ลงทะเบียนเมื่อ: 31/03/2014 10:02 am
- ติดต่อ:
- thatsawan
- PHP VIP Members
- โพสต์: 28508
- ลงทะเบียนเมื่อ: 31/03/2014 10:02 am
- ติดต่อ:
Re: "LEFT_JOIN" 2 ตารางใน phpBB จะทำยังไงค่ะ
ดูตัวอย่างมาจากที่นี่
https://wiki.phpbb.com/Dbal.sql_build_query
https://wiki.phpbb.com/Dbal.sql_build_query
- mindphp
- ผู้ดูแลระบบ MindPHP
- โพสต์: 41417
- ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
- ติดต่อ:
Re: "LEFT_JOIN" 2 ตารางใน phpBB จะทำยังไงค่ะ
tp., t.
หลัง WHERE
tp.ชื่อ field {เงื่อนไข} ค่า
AND/OR
t..ชื่อ field {เงื่อนไข} ค่า
หลัง WHERE
tp.ชื่อ field {เงื่อนไข} ค่า
AND/OR
t..ชื่อ field {เงื่อนไข} ค่า
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
-
- PHP VIP Members
- โพสต์: 1527
- ลงทะเบียนเมื่อ: 18/08/2014 10:01 am
Re: "LEFT_JOIN" 2 ตารางใน phpBB จะทำยังไงค่ะ
ตอน where เขียนด้วยคับว่า เอาตัวไหนตารางไหนมาเทียบ เช่น
topic_title เป็น tp.topic_title
topic_title เป็น tp.topic_title
- thatsawan
- PHP VIP Members
- โพสต์: 28508
- ลงทะเบียนเมื่อ: 31/03/2014 10:02 am
- ติดต่อ:
Re: "LEFT_JOIN" 2 ตารางใน phpBB จะทำยังไงค่ะ
ผิดประเด็นเเย้ว
วิธี LEFT JOIN 2 ตาราง คือแบบนี้
วิธี LEFT JOIN 2 ตาราง คือแบบนี้
โค้ด: เลือกทั้งหมด
$sql_ary = array(
'SELECT' => 'tp.*,t.forum_id, t.topic_title, t.topic_poster, t.topic_time, t.topic_first_poster_name',
'FROM' => array(
'phpbb_m_topic_portal' => 'tp',
),
'LEFT_JOIN' => array(
array(
'FROM' => array(TOPICS_TABLE => 't'),
'ON' => 'tp.topic_id=t.topic_id',
),
array(
'FROM' => array(USERS_TABLE => 'u'),
'ON' => 'u.user_id=tp.add_by',
),
),
'WHERE' => "forum_id = ". $db->sql_escape(utf8_clean_string($search))." OR topic_title LIKE '%"
.$db->sql_escape(utf8_clean_string($search))."%'OR topic_poster LIKE '%"
.$db->sql_escape(utf8_clean_string($search))."%' OR topic_time LIKE '%"
.$db->sql_escape(utf8_clean_string($search))."%' OR topic_first_poster_name LIKE '%"
.$db->sql_escape(utf8_clean_string($search))."%' OR username LIKE '%"
.$db->sql_escape(utf8_clean_string($search))."%' ",
'ODER BY' => 'tp.potal_order DESC',
);
- mindphp
- ผู้ดูแลระบบ MindPHP
- โพสต์: 41417
- ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
- ติดต่อ:
Re: "LEFT_JOIN" 2 ตารางใน phpBB จะทำยังไงค่ะ
เชื่อม ตอน JOIN
ตามตัวอย่าง คือ
tp.topic_id=t.topic_id
เป็นเงือน ไขสำหรับดึงค่าของสองตาราง
ตามตัวอย่าง คือ
tp.topic_id=t.topic_id
เป็นเงือน ไขสำหรับดึงค่าของสองตาราง
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
-
- Similar Topics
- ตอบกลับ
- แสดง
- โพสต์ล่าสุด
-
- 0 ตอบกลับ
- 1671 แสดง
-
โพสต์ล่าสุด โดย M030
19/10/2015 6:43 pm
-
- 6 ตอบกลับ
- 5212 แสดง
-
โพสต์ล่าสุด โดย M030
21/10/2015 4:30 pm
-
-
โพสต์ใหม่ สอบถาม เรื่อง Join ตารางของ phpbb
โดย AePongsak » 09/01/2018 7:09 pm » ใน สอบถามปัญหาการใช้ phpBB3, SMF, Joomla, Wordpress, CMS, CRM - 1 ตอบกลับ
- 1048 แสดง
-
โพสต์ล่าสุด โดย mindphp
09/01/2018 7:39 pm
-
-
-
โพสต์ใหม่ อยากทราบว่าค่า จุดเริ่มต้นของ left นับจากตรงไหน
โดย offing » 26/11/2014 11:18 am » ใน JavaScript & jQuery Ajax & Node.JS - 1 ตอบกลับ
- 1517 แสดง
-
โพสต์ล่าสุด โดย mindphp
26/11/2014 3:17 pm
-
ผู้ใช้งานขณะนี้
สมาชิกกำลังดูบอร์ดนี้: Google [Bot] และบุคลทั่วไป 96