Need some simple mySQL help.

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
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
Close
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
Close
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
Close
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
Close
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
Close
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
Close
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
Close
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
Close
CatchedCatched

We're social

Escrow.com
Spaceship
CryptoExchange.com
Domain Recover

NamePros updates

Quick replies: search, your most used replies, and more on every post
Quick replies are easier to find and use now. The quick reply menu has a search box. Type a few letters to find the reply you want. A...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back