Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.

php query

Status
Not open for further replies.
Joined
Jan 19, 2007
Posts
2,208
Reaction score
47
I have a table where there are a bunch of fields. I'm trying to extract information for rows with a unique 'code' where subject='subject'. I also need the 'title' field entry from that row.

Here's my query:

$query="select distinct(code), title from tablename where subject='$subject' order by code asc";


Is this correct or can it cause problems that of the 2 variables I'm pulling, I'm specifying 1 as disctinct?
 
theoretically if you ask the puritans your not supposed to pull more than one column when specifying distinct. As your using orderby the distinct you may wanna alias it and set distinct code as distcode then order by distcode, otherwise some SQLs will order by all the code not just the distinct ones. (there maybe 1000 code lines but only 15 distinct ones).

I personally think if it works then its ll good :)
 
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Featured Services

Sedo - it.com Premiums

IT.com

Premium Members

AucDom
UKBackorder
Be a Squirrel
Acorn Domains Merch
MariaBuy Marketplace

New Threads

Domain Forum Friends

Other domain-related communities we can recommend.

Our Mods' Businesses

Perfect
Service
Laskos
*the exceptional businesses of our esteemed moderators
Top Bottom