Jump to content

Problem with select distinct


Recommended Posts

Hey there, I have a SQL-statement in a stored procedure returning an employees name and his projects. The names are displayed in a list, and if an employee has n projects, his name is displayed n-times. I want the names to displayed only once, but still n projects. So if I click later on a name, his projects are highlighted or alternatively the others are greyed out. Is there a possibility to get this with only one SQL-statement? I've tried with "select distinct ..." but this doesn't cause any change Thanks for helping

Link to post
Share on other sites

I would use php to answer that question. I don't think there's a sql solution to it.

Link to post
Share on other sites

Thanks for the quick answer. I just tried a second SQL which is mostly the same, but only returns the names and distinct works fine.Unfortunately I don't have the skills to say if a php or a second sql is the better solution.

Link to post
Share on other sites

It's all about the resource that sql returns. You can't target something that's not in the sql resource that's returned. So, just do a mysql_fetch_array (you'll have to know a little php), then a var_dump(), then viola, you'll see what was actually produced.

Edited by niche
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...