Hi y'all, I have a php search that queries a mysql DB. Works fine for my needs, but I'd like to add a NOT function (if you will) to the query. So, word(s) not word(s), or word(s) -word(s). It would be nice to implement this filtering capability as the DB is getting large enough to return too many results (even though the presentation is paginated). Any ideas? Thanks. Robert
Better you post your current code so that experts here can see and say the solution. Just words,not words... etc wont be enough to understand AFAIK.
SELECT * FROM table WHERE something = 'item' AND something != 'item' Code (markup): "=" is equals and "!" stands for "does not" so "!=" is "does not equal" Hope that helps. PS: rajug, what he supplied is more than sufficient for me, and I wouldn't even consider myself an expert.
i think i have a similar problem... using mysql. on my one page i have 3 input values $datefrom $dateto $branch I can display these values on my second form but if i try and use them in my sql i get errors to do with initializing sessions i want to run this query select Amount,date,branch from table where date between $datefrom and $dateto and brn=$branch if i run that query without the where part i get nice results if i add that where part i get errors. how do i use those $ values in my sql?
I'm guessing you have an order problem (I assume $branch is not a date). Try: select Amount,date,branch from table where brn=$branch and date between $datefrom and $dateto
Okay branch is like region as in city or town the amounts are for different cities and dates if i try to use $field i the sql i get an error. you can try and open the page at URL="http://www.gravityweb.co.za/core/services.htm"]gravityweb[/URL] try the branch totals link The sql Below WORKS // sending query to show records between $datefrom and $dateto and branch=$brn only $result = mysql_query("SELECT branch_name,Date,Time,Receipt_No,Amount_Paid,Payment_Type,Payment_By FROM {$table} ORDER BY Branch,Date desc"); if (!$result) { die("Query to show fields from table failed"); If i add where Date between $datefrom and $dateto then i get the error
This is the error i get if i add $field into my sql Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0
i seemed to have found the solution by retrieving the value from the session thingie and then using that in the sql. the error does not appear anymore but i think now i just have to find a way to convert the values to a date so my sql will return records. for now there is no more error and the result is just blank with only the field names returned in one record. Thanks