0

Hi, I'm trying to select from 3 tables but I can't seem to get it right. Here is the code:

$query_Recordset1 = sprintf("SELECT * , image.user_id, image.name, page.user_id, page.urlcode FROM users JOIN mystuff.page JOIN mystuff.image ON page.user_id = image.user_id = users.user_id WHERE users.last_name = %s AND users.first_name = %s", GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname2_Recordset1, "text"),GetSQLValueString($colname3_Recordset1, "text"));

If I remove the page table it works perfect but when I add it in I have problems. Any thoughts?
Thanks!

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by jalicia18
0

I got it to work but still open to any suggestions.
Here is what I changed:

("SELECT * , image.user_id, image.name, page.user_id, page.urlcode FROM users JOIN mystuff.page JOIN mystuff.image ON image.user_id = users.user_id WHERE page.user_id = users.user_id AND users.last_name = %s AND users.first_name = %s"
0

You also try this

("SELECT * , image.user_id, image.name, page.user_id, page.urlcode FROM users JOIN mystuff.page ON (user.user_id=page.user_id) JOIN mystuff.image ON image.user_id = users.user_id WHERE page.user_id = users.user_id AND users.last_name = %s AND users.first_name = %s"
0

Hi, I'm trying to select from 3 tables but I can't seem to get it right. Here is the code:

$query_Recordset1 = sprintf("SELECT * , image.user_id, image.name, page.user_id, page.urlcode FROM users JOIN mystuff.page JOIN mystuff.image ON page.user_id = image.user_id = users.user_id WHERE users.last_name = %s AND users.first_name = %s", GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname2_Recordset1, "text"),GetSQLValueString($colname3_Recordset1, "text"));

If I remove the page table it works perfect but when I add it in I have problems. Any thoughts?
Thanks!

Try this one out
Table: image | page | mystuff | users
Fields: image = user_id | image.name |
page = user_id | urlcode
mystuff = image
users = user_id | last_name | first_name

$lastname = $_GET[lastname]; //use is GET form
$firstname = $_GET[firstname]; //use is GET form

$sql = "SELECT * FROM users a, page b, image c, mystuff d WHERE a.user_id=b.user_id ";
$sql .= "AND a.user_id=c.user_id ";
$sql .= "AND b.user_id=c.user_id ";
$sql .= "AND a.last_name LIKE '%$lastname' ";
$sql .= "AND a.first_name LIKE '%$firstname' ";

$result = mysql_query($sql);
/*
display here the mysql_fetch_array and echo the result.
*/

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.