NameSilo

Need some simple mySQL help.

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
NamecheapNamecheap
Watch

jimb0t

Marketing MachineEstablished Member
Impact
3
I need to find a way to edit multiple entries of an item in my table without having the need to go through each one of them individually. There are 36,000 records and that would be a very huge pain to have to do that.

However I only want certain ones to be edited assuming they match another value in the row. Please see the attached image to get a better idea of what I am trying to say.


This is part of my jos_postalcodes3 table. This is one example of what I am trying to do. Of course I need to do a whole lot more but hopefully it is a simple piece of code I can work off of.

2vxhohe.jpg


Thanks in advance for the help.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
update jos_postalcodes3 SET countyname = 'Albany (NY)' where countyname = 'Albany' AND county_zip = '36001';

That should do it ...
 
0
•••
Code:
UPDATE `jos_postalcodes3` SET `countyname`='Albany (NY)' WHERE `countyname`='Albany' AND `county_zip`='36001';


just change the table name for different tables. sometimes the quotes around things matter (column names and table names have the mark that's on the button above TAB button on keyboard and other quotes are normal single quotes)
 
0
•••
nasaboy007 said:
Code:
UPDATE `jos_postalcodes3` SET `countyname`='Albany (NY)' WHERE `countyname`='Albany' AND `county_zip`='36001';


just change the table name for different tables. sometimes the quotes around things matter (column names and table names have the mark that's on the button above TAB button on keyboard and other quotes are normal single quotes)

They are called tics and should only really be used if the table names or column names are reserved words in the database being used.
 
0
•••
Peter said:
should only really be used if the table names or column names are reserved words in the database being used.

Really? I've run into problems multiple times where I tried doing queries without ticks and they just didn't work. I know they weren't reserved words. However, the same code/query would work on different hosting servers. (example: works on localhost, doesnt work when uploaded to godaddy/etc). Would it have something to do with the version of mysql or anything?
 
0
•••
nasaboy007 said:
Would it have something to do with the version of mysql or anything?

Different versions of mySQL have different keywords. Can you remember the queries that failed on Godaddy?
 
0
•••
I can't remember them exactly, but it's happened multiple times with completely different tables. Only thing I can remember (it was so long ago) was that they all had "id" as a field.

It just happened too many times so I've just used ticks ever since, regardless of if it worked with or without them. Is there any detriment to using ticks?
 
0
•••
Besides reserved words, you need the ticks if the names contain spaces or hyphens (underscores are OK and don't require special treatment).

Doesn't HURT to use them as a matter of course, I don't use them where I don't need them because I'm lazy :).
 
0
•••
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover
URLs.com
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back