Hi all,
I am fed up with this simple query ??can anybody tell me what is wrong with it .. it dosen't fetching any rows ..
$sql = "select * from profile where username='$username1' and username='$username'";
?????????
thanx tabish
Yeah, you're asking for a row that has 'username' equal to two different variables... that's not possible, which is why it's not selecting any rows.
so how can we select the entire information about 2 users in a single select statement ??
Try OR instead of AND in your WHERE clause
Basically it would read $sql = "select * from profile where username='$username1' OR username='$username'";
Also, if you are using mysql you could write it like this $sql = "select * from profile where username IN('$username1', '$username')";
$sql = "SELECT * FROM profile WHERE username ='$username1' OR username='$username';
That will work in most other databases too, like postgresql. Except you could also do it like this:
select * from profile where username in ('select username from profile where groupname='usergroup' and building='A');
Or some such thing.
Thanx everybody..
I think I have got enough select statements from so many different aspects..
thanx..