Page 1 of 1

select from sql table

Posted: Sat May 22, 2004 10:57 pm
by merican
hi all,
I need to know how to select data from 2 different table in sql. below is the code i use to select data from 1 table:-

$ffdb->DivideData("SELECT * FROM ffdb_files ORDER BY file_name",$page,$CONFIG['files_per_page']);
$ffdb->MakePages("<a href=\"admin.php?page={eachpage}&action=edit_file\">{eachpage}</a> ","<b>({page})</b> ","<a href=\"admin.php?page=1&action=edit_file\">« First Page</a> ","<a href=\"admin.php?page={eachpage}&action=edit_file\">Last Page »</a>",$page,$ffdb->num_pages);
$tpl->LoadTemplate("file_list","Admin/templates/$admin_skin/file_list.tpl");
$mysql->Query("SELECT * FROM ffdb_files ORDER BY file_name LIMIT $ffdb->data_bottom,$ffdb->data_top");
while ($show_file=mysql_fetch_array($mysql->result_id)) {
$has_files=1;
$file_list_array = array(
'file_filename'=> $show_file[file_filename],
'category'=> $show_file[category],
'file_description'=> $show_file[file_description],
'author'=> $show_file[username],
'author_email'=> $show_file[author_email],
'version'=> $show_file[version],
'file_id'=>$show_file[file_id]
);


let say i want to selet username from the filedb_users table. can anyone help me? thank you in advance.

Regards,
Alfy Merican

Posted: Sun May 23, 2004 5:19 am
by launchcode
Post your SQL table (in code tags please, so it's easier to read).

Is the data you want to retrieve from the two tables related in any way?

Posted: Sun May 23, 2004 10:01 am
by kettle_drum

Code: Select all

SELECT table.field, table2.field2, FROM table, table2 WHERE table.ID = blah AND table2.ID = 'this'
You just have to refer to each field using the table name before it.

Posted: Sun May 23, 2004 9:15 pm
by merican
hi guyss..
thank you for your knowledge. It works man...now i can see data from 2 different table...thanks....really appreciate that!!!

best regards,
Alfy