MySQL "OR" Statement Question

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?

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 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 ...

MySQL sql statement question

i encountered the following behavior that i didn't expect and do not understand. say i have 3 tables. CREATE TABLE A (id int auto_increment, type int, primary key(id)) CREATE TABLE B (id int auto_increment, primary key(id)) CREATE TABLE C (id int auto_increment, primary key(id)) assume - table A has ...

jQuery simple if-statement question

i want to make an if-statement that checks if the div is a certain width (either by class or id... doesn't matter) then executes the code if, for example, the div (named "top") equals 130px... how do i write the syntax? ...

jQuery DatePicker mysql connectivity question

Hi,I am glad jquery has a forum of it's own I just found out!!!Like the subject says, I am wondering if making a mysql or sqlite database act as a backend for the date picker. I am trying to make an application just to learn jquery and php and I would like to have a calender that authenticated users ...

PHP/MYSQL newbie question

here is my code:// user_profile is a table// password is a field in user_profile$selectStmt = "select password from user_profile WHERE userid=$form_userid";if (!($mailpwd = mysql_query($selectStmt, $link))) {DisplayErrMsg(sprintf("Error in executing %s stmt", $selectStmt));Displa ...

MySQL Simple question on linking to a database using ODBC

Newbie question: I want to link to table versus doing an import of that table. Is there a way to do this? I find that I can only do an import of data using the Import/Export Wizard. ...

MySQL database question

I use Open Office & need a database. I don't necessarily need a big one. I have been using MS Works databases, but it won't run under XP even in compatible mode so I have been using spreadsheets & saving to db which truncates data. I need a few suggestions about which one is best to download ...

Execution time of mySQL statement

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

Problem with GRANT syntax in MYSQL statement...need help!

Good afternoon all! I need a little help with some mysql syntax. I'm using version 4.0.17, and I'm just starting to try to learn about connection pooling. I'm following the directions contained on Apache's website (http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html) ...

MySQL grouping question

everyone, this is my first post here. I maintain a blog, and I would like to list the latest 3 blogs commented on. I am having trouble coming up with a query that effectively searches by date DESC and groups by BLOGID. Say I had a few rows like this: id=1 date=11-27 blogid=7 id=2 date=11-28 blogid=1 ...

MySQL Subqueryes question

I want to select some values from one table, where some value is equal to some data selected from table from DIFFERENT database. how to point to this different database? ...

MySQL lock question

I am a new mysql user. This is a question for the classic edition of mysql. I know that in the pro edition the InnoDB has a row-level locks and I wanted to know if there is any protection ( lock or something like that ) in the classic edition as well. I want to know this beacuse I want to know if 2 ...

MySQL newbie question re: user login

all, I'm a little confused with the following concep, and it's hard to explain. user logs in to the database via a website, and sees user-specific content, such as his profile, no one else's. That's fine, but what I don't understand is: user/pass/login checks are made against the inherant MYSQL data ...

MySQL subquery question.

I've tried to do this query. ============= qry starts ======================================== SELECT SDATE, SSTONUM, SUM(SQTY ) FROM ( SELECT SUBSTR(DATE,-5) AS SDATE, STONUM AS SSTONUM, QTY AS SQTY FROM TTAB ) AS TT GROUP BY SDATE, SSTONUM ============= qry ends =================================== ...

MySQL Query Question

I have two tables, customer table and insurances table. Customer table: customer autoincrement (primary key) name varchar .... Insurance table: company varchar(6) insurance carchar(13) customer integer .... i need to filter the customers that add insurances only in company 'axa' ist's possible? ...

MySQL Maths Question

I want to retrieve data from a MySQL database through a PHP web page. Now the problem is I’ll need to do some maths on the data (like plus, minus, divide etc.). Would I need the SQL Query to do the maths or should the maths be done in the PHP coding before it's displayed? ...

MySQL Hi... question re: UNION

These two selects by themselves work fine and produce good results, but when joined by UNION seem to ignore the second SELECT... (SELECT search_detail.*, MATCH (search_index.name,search_index.type,search_index.cat_1) AGAINST ('$keywords') AS score FROM search_index, search_detail WHERE MATCH (search ...

MySQL index question

how do i set up a constraint where given two rows: 1 1 ok 1 0 ok 2 2 ok 1 2 ok 1 1 wrong:constraint picks up error here because it has already seen that pair. never allows same pair of data twice. question is how do i set up this constraint. can't seem to find the awnser on the internet. have found ...

MySQL This question is as basic as it gets

I am so new to trying to learn php/mySql that and havbe been looking for online tutorials for using php with mysql, and then actionscript with these. I have found some tutorials and they talk about needing webservers running mysql and php which I have, they then include code for populating a databas ...

MySQL Query question?

+---------------------+ |name|address|amout$| -----+----------------+ | A |street1| 125 | +----+----------------+ | A |street1| 50 | +----+----------------+ | B |street2| 70 | +----+----------------+ | C |street3| 80 | +----+------------- --+ Is it possible to make a view from the first table to loo ...

MySQL syntax question whole word finding

Is there a way to construct a query to select for whole words only? select id from bookdata where titles like '%Test%' gets everything with test somewhere in the field. What I am interested in is finding individual words in a stored field. Say a field has 'Test your knowledge on this one.' and you w ...

MySQL FreeText Question

I recently started switching a major e-commerce website over to MySql from MS Sql server, one of the reasons for this was to utilize FREETEXT which the host does not support under MS Sql. The FREETEXT searches for text descriptions of parts in the database works wonderfully. I can't believe that I w ...

MySQL noobie question

I have the following issue. I have a forum in which people use several languages and I want to change the encoding for the whole database to UTF-8, that means I also want to convert excisting posts. I already fixed the PHP part to output UTF so that is all cleared. However after reading online manua ...

MySQL wildcard question

New to mysql. I want to select certain data in a table ive created. The table is called example and has names and ages in it. I want to extract the data with all the people who are in there Twenties. I got some code from a website and rearanged it to suit my needs to get into the database. $result = ...

MySQL Quick question about altering location of data directory on Linux

I have very little space left on my primary hard drive and I would like to change the location of my data directory from /var/lib/mysql to somewhere in my /home/ directory (which is a different hard drive). How do I do this exactly? I know I should change the my.cnf file to point "datadir" ...