Membership is FREE, giving all registered users unlimited access to every Acorn Domains feature, resource, and tool! Optional membership upgrades unlock exclusive benefits like profile signatures with links, banner placements, appearances in the weekly newsletter, and much more - customized to your membership level!

php query

Status
Not open for further replies.
Joined
Jan 19, 2007
Posts
2,207
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!

Members online

No members online now.

Premium Members

New Threads

Domain Forum Friends

Our Mods' Businesses

*the exceptional businesses of our esteemed moderators
General chit-chat
Help Users
  • No one is chatting at the moment.
      There are no messages in the current room.
      Top Bottom