Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
vishnujayvel
Starting Member
1 Post |
Posted - 2012-06-27 : 07:00:19
|
| can u tell me whether the syntax for this query is ri8?conditions within brackets are supposed to be executed first. thanks in advance $q="select * from chat where from=($_SESSION['user_name'] or $_GET['user2']) and to=($_SESSION['user_name'] or $_GET['user2']) by chat_id desc"; |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-06-27 : 07:11:45
|
quote: Originally posted by vishnujayvel can u tell me whether the syntax for this query is ri8?conditions within brackets are supposed to be executed first. thanks in advance $q="select * from chat where from=($_SESSION['user_name'] or $_GET['user2']) and to=($_SESSION['user_name'] or $_GET['user2']) by chat_id desc";
Are you using Microsoft SQL Server? This forum is for MS SQL, so if you are on another DBMS, you would get better/faster answers at other forums such as dbforums.comIf you are using MS SQL "from" and "to" is not valid T-SQL syntax. The correct syntax would be "BETWEEN xxx AND yyy". In your example, even if you changed the syntax, that would not be correct because the OR operator returns a boolean. The xxx and yyy has to be of the same data type as that of the value/variable that comes before the between.What is the logic you are trying to implement? Can you post representative examples? |
 |
|
|
|
|
|