Unstoppable Domains โ€” AI Assistant

SQL Help

SpaceshipSpaceship
Watch
Hey guys,

I am trying to run a SQL command:

SELECT * FROM businesses WHERE website !='' ORDER BY company_name ASC;
SELECT * FROM businesses WHERE website ='' ORDER BY company_name ASC;

But I want this to be one SQL statement. Basically, I want to select businesses that have a website and order by company, then after order by company that does not have a website.

I don't want to do:
SELECT * FROM businesses ORDER BY website DESC, company_name ASC; because then it sorts by website reverse alphabetical.

Does this make sense? Any help would be great.

Thanks,
Shaun
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Use:

Code:
SELECT * FROM businesses ORDER BY website!='' DESC, company_name;
 
1
•••
Use:

Code:
SELECT * FROM businesses ORDER BY website!='' DESC, company_name;

Sweet. Thanks a lot!

---------- Post added at 01:13 AM ---------- Previous post was at 12:30 AM ----------

I have one more question. This is a little bit harder. I have a zipcode field. If someone searches a zipcode I need it to order by distance. My PHP script can do that, but it needs to order in that zipcode distance, followed by Website !='' DESC, company_name.

How would I do that?
 
0
•••
You'll need the SQL to determine the distance if you plan on having it order them all at once.

If you don't already have it, download the Zip code database which includes the coordinates of all US zip codes and take a look at the Google store locator tutorial for instructions on finding the distance using SQL.
 
0
•••
CatchedCatched
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy โ€” Zero Commission
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back