Posted by: Nanta on: August 17, 2007
This Article have been moved at Show Data with Join 3 Tables MySQL
i need a support on how to join 3 to four tables in a database using mysql select but it keeps repeating 1 no throughout..i need the query to do that..like am joining these four tables together now
account payment,account trxn,savings_trxn_details and the relationship among them is the account id but one of them does not have the account id and i want the details on the other to appear on the same table with them..
thanks
andrew
wow,.. great post I should say. Was looking for join and after reading your post and add in some join with your left join, my sql are working!
Again, Thanks = )
Oh, you are the man! It took me a while to google if 3 joins were even possible!
Thanks!!!!!
Thank you so much!! It works for 4 tables too
[quote]
$sql=mysql_query(“SELECT title_post, post, id_category, id_topic FROM posting_forum
LEFT JOIN topic_forum ON posting_forum.id_topic = topic_forum.id_topic
LEFT JOIN category_forum ON posting_forum.id_category = category_forum.id_category ORDER BY id_post”);
$x=mysql_fetch_array($sql);
echo “Topik: $x[title_topic]“;
echo “”;
echo “Intro: $x[intro]“;
echo “”;
echo “Category: $x[title_category]“;
echo “”;
echo “Title: $x[title_posting]“;
echo “”;
echo “Post: $x[post]“;
[/quote]
My DataBase:
tbl>1 posting_forum
id_post
id_category
id_topic
title_posting
post
tbl>2 category_forum
id_category
title_category
tbl>3 topic_forum
id_topic
title_topic
intro
———————————————————————————-
I have an error in result :
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\work\showpost.php on line 8
I also rename the fetch_array function to num_rows but still got the same error. Please help me wats wrong with my query or script?
Thank for the help….
I`m sorry, the error was only title_post and post that showed up on the browser. But the title_topic, intro and title_category was blank. Something wrong with my query???
I`m very sorry about the error….
The error was not:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\work\showpost.php on line 8
I need to write a query which get array of data from one table and then search in second table at basis of result..Please help me..I can forward my code its only return me one record and search that one rec in second table ..I wanna get more then one rec Please Please Please help me out..
thank, is ok,..is very imfortan for me..
June 11, 2008 at 5:53 pm
good help