ariel
ariel

Reputation: 3082

How to create a OR statement in one query?

How do i make a OR query for something like this?

//Query
$sql = "select `Friend_status` from `friendship_box` where 
`system_id` = '$sid' and `friend_id` = '$friendis' OR 
`system_id='$friendis' and `friend_id` = '$sid'";
$query = mysql_query($sql) or die ("Error: ".mysql_error());

while ($row = mysql_fetch_array($query)){
$activity = htmlspecialchars($row['Friend_status']);
}
mysql_free_result($query);

Upvotes: 0

Views: 66

Answers (1)

juergen d
juergen d

Reputation: 204924

select `Friend_status` from `friendship_box` 
where (`system_id` = '$sid' and `friend_id` = '$friendis')
OR (`system_id`='$friendis' and `friend_id` = '$sid')

you missed the ` here:

...OR (`system_id` <--

Upvotes: 2

Related Questions