Link to home
Start Free TrialLog in
Avatar of NewWebDesigner
NewWebDesigner

asked on

Trouble with creating MySQL query

I have a database with 1000s of entries.  I need to change the values of one column called 'stateName'.  I would like to select the rows to change by saying something like "FROM air university to Alabama University, stateName= 2"

Can anyone write the appropriate SQL query to carry out that function?
Avatar of kaufmed
kaufmed
Flag of United States of America image

Try the following. You may get by with removing the LOWER, but I think it may be required for string comparisons.
SELECT *
FROM tblName
WHERE LOWER(statename) BETWEEN 'air university' AND 'alabama university'

Open in new window

so you want to change "Air University" (let's say statename = 1) to "Alabama University" (statename = 2)? If so, use update:

UPDATE yourTable set statename = 2 WHERE statename = 1
Avatar of hackpin
hackpin

i guess this should be the answer...


update  tblName set statename = 'any'
WHERE fieldname between 'brazil' and 'canada'
Avatar of NewWebDesigner

ASKER

Well,
this didn't work:
$sql = "DELETE 
FROM universities2
WHERE BETWEEN 'Faulkner University' AND 'Stillman College'";

Open in new window


Neither did this:
$sql = "DELETE 
FROM universities2
WHERE universityID BETWEEN LIKE '%Auburn University at Montgomery%' AND LIKE '%Huntsville%'";

Open in new window


any other suggestions?
Do you want to delete the records
can you told me in which firld 'Faulkner University' these values are store there you need to give the between
if it stored in fieldname like uname then query will be


$sql = "DELETE
FROM universities2
WHERE uname BETWEEN 'Faulkner University' AND 'Stillman College'";
I want to change the column called stateID to 2.  I do not want to delete these records.

So I came up with this and it still doesn't work.  Lets see if someone can fix this:
$sql = "UPDATE universities2
SET stateID='2' WHERE unversityID BETWEEN '8' AND '14'";

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Pratima
Pratima
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
THE man, thanks
THE man, thanks
Not according to her Eeple  ; )
my bad, sorry Pratima, nonetheless thank you.