MySQL "OR" Statement Question


Advertisements

I'm working on a script that selects a list of schools, and displays them according to the user's specified criteria.

Here's the query I'm using at the moment

Quote:
"SELECT * FROM hs_ajax_suggest WHERE hsName LIKE '".$param."%' OR hsCity LIKE '".$param."%' OR hsState LIKE '".$param."%' LIMIT 10")
This seems really wrong to me. I don't even know if "OR" is a valid statement. I'd like to know how to get a more structured query, and a more relevant response from this query.

Do you guys have any suggestions?

Smilar Topics

  • Newbie MySQL Statement Question

    HiCan any1 hell me whats wrong with this:$sql="SELECT * FROM user WHERE username='$username' AND password='". md5($password) ."' AND usergroupid='5' or '6' or '7' or '8'";thanxJonathan ...

  • MySQL Expert question : Tree query : How to format the output of a self JOIN not to generate an additional column ?

    How to format the output of a self JOIN not to generate an additional column ? I am not sure if this is a newbie question but I haven't used SQL much : For the following Tree : myTree NodeID NodeType ParentID ChildID given the tree 5 6 \/ 8 8 1 0 0 ... 11 2 5 8 12 2 6 8 Using "Left join ... as ...

  • Execution time of mySQL statement

    How can I get the execution time of a mySQL statement ?Thank you for your help.Best ...

  • MySQL username question

    I just installed MySQL on my Mac with OS X 10.3, Apache and PHP. I thought installing and getting started with MySQL would be tricky like a lot of developer stuff on unix machines with builds and everything. It was easy!! And the online tutorial/reference got me going in minutes. Really great! Thank ...

  • MySql statement help [urgently]

    i need help here... My sql statement is $query = "SELECT * FROM ei_module m, ei_student s, ei_result r WHERE r.admin_no LIKE '". $adminno ."' AND r.exam_grade = 'A' AND r.module_code = m.module_code AND s.admin_no = r.admin_no";what i want to get is to display results with both G ...

  • Problem in mysql statement and if condition

    Good day!I have code to check if the cloth type is NW or W for the operation name Operation3, Operation4, and Operation5. NW = AAA, BBB, CCCW = all cloth that was not belong to NWHere is the code I want to ask for you if correct and if I have missing code, because I’m not good in if condition and m ...

  • Mysql Statement not working?

    I have the following PHP code on a password resetting form...if($_POST['fpassword'] == $_POST['fvpassword']) {$query = "UPDATE " . $tblpref . "members SET password= ( '" . $_POST['fpassword'] . "' ) WHERE `username` =" . $_GET['username'] . ";";$putdata = mysq ...

  • MySQL trigger question

    We have to 2 web applications running in 2 different server and mysql. My question is it possible to use trigger to sync a table in the 2 database running in different server?Edited 2 time(s). Last edit at 07/17/2008 01:46AM by jack mapa. ...

  • Problem in mysql statement and if condition

    Good day!I have code to check if the cloth type is NW or W for the operation name Operation3, Operation4, and Operation5. NW = AAA, BBB, CCCW = all cloth that was not belong to NWHere is the code I want to ask for you if correct and if I have missing code, because I’m not good in if condition and m ...

  • Need help for mysql statement. urgent

    i need help here... My sql statement is $query = "SELECT * FROM ei_module m, ei_student s, ei_result r WHERE r.admin_no LIKE '". $adminno ."' AND r.exam_grade = 'A' AND r.module_code = m.module_code AND s.admin_no = r.admin_no";what i want to get is to display results with both G ...

  • Variable in MySQL statement

    HiI am collecting info from my mysql db, when running$result = mysql_query("SELECT free from jan where free!=0");everything is fine but when I replace the table name with a variable$result = mysql_query('SELECT free from '$_SESSION['table']' where free!=0');I getParse error: parse error, u ...

  • Help on mysql statement

    I"m trying to create a mysql statement in which includes everything on tableA that has the work 'hi' in it and but exclude everything in tableB that has 'die' in it and also from tableC that has 'fry' in it. This is what i have now"SELECT * FROM this_table WHERE file_description LIKE '%hi% ...

  • debugging correct mysql statement

    I am having a mysql error of "You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1"But i have sevral on die statments in my page, is there anyway to try and distinguise which mysql statement it is ...

  • Creating MySQL statement to pull any value that exists in one table, but not another

    I want to prune my user's table. Here's how it works. When they register on my site, they are created in the pn_user table. Then, when they enter the forum for the first time, their username is also entered into the pn_phpbb_user table.I would like to run a simple mysql statement that will give me a ...

  • Help with Mysql statement

    I have a table called "raw_leads" that has a field called "list_id" I need to list how many of each list id there is.Example:101010101010111111111000I would want to return:1010 31111 21000 1I can do it with php by using an array but I am sure there is a mysql statement that would ...

  • MySQL statement

    This MySQL statement fails, but I can't see why$sql = "DELETE FROM delivery_address WHERE (id = '$webuser') AND (title = '$delete_title') AND (first_name = '$delete_first_name') AND (last_name = '$delete_last_name') AND (address_line_1 = '$delete_address_line_1') AND (address_line_2 = '$delete_ ...

  • Using PHP in a MySQL statement?

    Is it possible to use PHP in a MySQL statement?For example, could I do...AND $row['signedup'] == "$allowedtime >= $time"If not, how would I go about this? ...

  • Mysql statement is throwing error.. why?

    I have been trying to debug this mysql statement for the past 2 hours.. here is the statement:$sql1 = "SELECT * FROM cpmip WHERE adid='$a' and ip='$ip'";$res1 = mysql_query($sql1) or die(mysql_error());I just can't figure out why this won't work.. it throws the following error:You have an ...

  • Problem in mysql statement and if condition

    Good day!I have code to check if the cloth type is NW or W for the operation name Operation3, Operation4, and Operation5. NW = AAA, BBB, CCCW = all cloth that was not belong to NWHere is the code I want to ask for you if correct and if I have missing code, because I’m not good in if condition and m ...

  • Problem in mysql statement and if condition

    Good day!I have code to check if the cloth type is NW or W for the operation name Operation3, Operation4, and Operation5. NW = AAA, BBB, CCCW = all cloth that was not belong to NWHere is the code I want to ask for you if correct and if I have missing code, because I’m not good in if condition and m ...

  • MySQL SQL select statement question

    I have a table with fields Name, Company, Address, City, State, Zip, Guest1, Guest2 This table is for a conference registration. Someone from a particular company can sign up and bring up too two guests. Of course we really have first name, last name, and title, but I'm hoping that shouldn't matter ...

  • MySQL Select statement - Question 2

    Ok, my second (and hopefully last) question: In a search page, i am having to make 2 separate queries: One to get the COUNT of results from a search, and one to get the actual results themselves. I know that there must be a way to do this all with one query, but i can't seem to get it. I'm doing thi ...

  • MySQL Quick question on using select statement

    New to MySQL. Not sure if this is possble, but it seems like it should be. I have a DB of 3 columns: Col A=int, Col B=int, Col C=int. I would like to do the following: Select * from TABLE where Col A = (int 1, int 2) and (Col B | Col A int 1) = (Col B | Col A int 2). i.e. select any entries where Co ...

  • MySQL Prepared Statement question

    I am trying to use a prepared statement in my stored procedure: ... DECLARE vOldValue INT; DECLARE sql_text VARCHAR(1024); START TRANSACTION; SET @sql_text = CONCAT('SELECT ', pField, ' INTO vOldValue FROM ', pTable, 'WHERE BookStem = ''', pBookStem, ''';'); PREPARE stmt FROM @sql_text; EXECUTE stmt ...

  • Getting a result from a mysql statement

    I think this should be an easy question but I've been teaching myself vbscript and mysql and could just use a little help with the following: I want to use the statement: SQL = "SELECT AVG (cut_pressure_avg) AS cut_pressure_average FROM record WHERE wordate='" & WorkDate & "' ...

  • Help with mysql Delete question please

    - i'm using mysql version 4.0.20 - i asked this question in a couple of other forums, but i'm afraid i made it too long-winded, and haven't received any responses : ( - i really need to get this figured out - so i will try to shorten it here:I want to perform a typical "cascade" type delet ...

  • MySql general question

    mysql community! I have an application that once in a second or something like that will query mysql database for table X. However it is imposible to predict when table X will be updated.Thus there are lots of "wasted" X queries that returns same data as previous queries. My question: is t ...

  • if not null then select in a mysql statement Post

    hiI am wondering if there is a better way to do this?SELECT (SELECT title from jnl_article WHERE blog_id = jnl_id) AS title,DATE_FORMAT(date, '%D of %M %Y at %l:%i %p') AS datetime,IF(folder IS NULL, 'none', folder) AS folder,IF(folder IS NULL, 'none', (SELECT filename FROM jnl_main_image WHERE blog ...

  • MySQL statement that behaves similarly to a "foreach" or "while"

    I had a quick question about a MySQL query I need to implement. What I want to do is to select everything in a table for the most recent date for each pid.I have tried the following:select * from versionData where date=(select max(date) where pid=pid)And clearly it doesn't work.What I'd like to do i ...