Show all that BEGIN with specific letter

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
palmere
Forum Newbie
Posts: 17
Joined: Fri Mar 19, 2004 5:33 pm

Show all that BEGIN with specific letter

Post by palmere »

Hey guys, I'm a complete newbie to this forum and somewhat of a newbie to php all together. I'm wondering (and I'm sure there is) some easy way to display all the entries that BEGIN with a specific letter.

In my case, I have a database that has artist names in it, and I want to be able to create a dynamic page that lists all artists that begin with a, b, and so on.

Thanks much.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

2 ways:

Make use of like and %

Make use of substring
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

Code: Select all

$letter = "a";
$sql = "SELECT name FROM Artists WHERE name LIKE '$letter%'";
palmere
Forum Newbie
Posts: 17
Joined: Fri Mar 19, 2004 5:33 pm

Post by palmere »

Well, I posted this question a long time ago before I left on vacation expecting that someone would eventually get back to me...

little did i know that there would be 2 replies in a couple minutes of my post. Thanks a ton guys. Got it figured out.

E
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Good holiday then, I hope? ;)
palmere
Forum Newbie
Posts: 17
Joined: Fri Mar 19, 2004 5:33 pm

Post by palmere »

Heck yeah,

With skiing in Colorado, gambling and Vegas and camping in Utah, you can't go wrong.

E
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

eeeeh

last time I went skiing, I ended up with a sore buttox. :evil:

last time I went camping I didnt catch any fish, when my buddies caught the mininum of 4 :evil:

grr! lol... Fun though none the less :roll:
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

You must be grateful you haven't been gambling, tim ;)
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

patrikG wrote:You must be grateful you haven't been gambling, tim ;)
On the contrary, i been known to wipe out some peoples pockets when it comes to the ole poker ride. Hence why i'm usually not welcomed to play =]
Post Reply