Fsoft Posted November 11, 2008 Share Posted November 11, 2008 Hey Friends, Well I have a database and a table into it, The table have 4 fields, name, surname, country , idnumber, status! NOW ID NUM is int and auto inrement and all others are Vachars. This table have ten entries inside of it, but the problem is that there are 8 entries simliar, but in that , all the 8 names are same Ali, but in four the country is set to be India and in other it's set to be pakistan, but 6 of them have a status of V.I.P. Now the problem is , if I run a query saying "SELECT name from member where country = pakistan"; it will grab out all the names which corespond to Pakistan and they have three V.I.P and a normal person...there. But the problem is I want to run something "SELECT name from member where country = "Pakistan" & status = "V.I.P"; in this sense it will only show me up 3 Alis from paksitan who are V.I.P and fouth one will be not shown to me, But WHERE doesn't work with double condition , not for me with the code I wrote above, I might made some mistake, Please help me I want somethign to be like this "Select somthing from table where condition1 = something & condition2 = something; Hope I made it clear enough, Please help, thanks a lot, FAISAL! Link to comment https://forums.phpfreaks.com/topic/132224-php-mysql-select-double-argument/ Share on other sites More sharing options...
.josh Posted November 11, 2008 Share Posted November 11, 2008 && Link to comment https://forums.phpfreaks.com/topic/132224-php-mysql-select-double-argument/#findComment-687355 Share on other sites More sharing options...
corbin Posted November 11, 2008 Share Posted November 11, 2008 In PHP it's &&. In MySQL, it's AND. "SELECT name from member where country = "Pakistan" AND status = "V.I.P"; Edit: Hrmmm, actually I've just always seen/used AND. I guess && works too. (Gonna either test or google it in a second.) I had assumed he was talking about in PHP, but perhaps I shouldn't assume ;p. Link to comment https://forums.phpfreaks.com/topic/132224-php-mysql-select-double-argument/#findComment-687362 Share on other sites More sharing options...
.josh Posted November 11, 2008 Share Posted November 11, 2008 You can indeed use && or AND in mysql (and php). They have different orders of operation though. Link to comment https://forums.phpfreaks.com/topic/132224-php-mysql-select-double-argument/#findComment-687372 Share on other sites More sharing options...
corbin Posted November 11, 2008 Share Posted November 11, 2008 Yeah, that's what I figured once I googled and found out that && is valid in MySQL. Seems the order of operations is the same in PHP/MySQL. Makes sense I guess. Link to comment https://forums.phpfreaks.com/topic/132224-php-mysql-select-double-argument/#findComment-687380 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.