Mysql query

Hello all,i just want to ask if there is a way(must be) to select a specific user from a query,my code is like this

$dbhost = ‘localhost’;
$dbuser = ‘root’;
$dbpass = ‘’;
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or
die (‘Error connecting to mysql’);

$dbname = ‘info_zi’;
mysql_select_db(‘info_zi’,$conn);
mysql_select_db(‘users’,$conn);

$query = "SELECT * FROM info_zi.sheet1 JOIN lr.users ON (info_zi.sheet1.nr_matricol = lr.users.nr_matricol) ";
$result = mysql_query($query);

I need to show just one user that has the same data (nr_matricol) both in info_zi and in users.

Yes, You can definitely query a specific user…

[php]SELECT * FROM info_zi.sheet1 JOIN lr.users ON (info_zi.sheet1.nr_matricol = lr.users.nr_matricol) [/php]

you just need to add a “WHERE” clause on your statement… Something like this below, but I have no clue what the column names are in your users table, so you will have to replace the user_id with the correct column name and change the value to the correct value. You can post your attempt here and we can modify it for you if it doesn’t work.

[php]SELECT * FROM info_zi.sheet1 JOIN lr.users ON (info_zi.sheet1.nr_matricol = lr.users.nr_matricol) where lr.users.user_id = 5[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service