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?
Can anyone write the appropriate SQL query to carry out that function?
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
UPDATE yourTable set statename = 2 WHERE statename = 1
i guess this should be the answer...
update tblName set statename = 'any'
WHERE fieldname between 'brazil' and 'canada'
update tblName set statename = 'any'
WHERE fieldname between 'brazil' and 'canada'
ASKER
Well,
this didn't work:
Neither did this:
any other suggestions?
this didn't work:
$sql = "DELETE
FROM universities2
WHERE BETWEEN 'Faulkner University' AND 'Stillman College'";
Neither did this:
$sql = "DELETE
FROM universities2
WHERE universityID BETWEEN LIKE '%Auburn University at Montgomery%' AND LIKE '%Huntsville%'";
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'";
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'";
ASKER
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:
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'";
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
THE man, thanks
THE man, thanksNot according to her Eeple ; )
ASKER
my bad, sorry Pratima, nonetheless thank you.
Open in new window