The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Query Field, Explode, Compare, ReQuery (Or Something like that)

Hey guys, I have a brain-buster here, I can't figure her out. Please help me I can't figure out the right logic or plan of action.
What im trying to do: Im checking a field in every project to see if it the assign_users == session. If it does, I want to list all the projects where it contains this match.

I first gather the Data:

PHP Code:

SELECT `assign_users` FROM `projects`;

And something like this is returned:

PHP Code:

$Row1_Example = '1,5,3,7'; // Note: This is just a VARCHAR from DB$Row2_Example = '1,9,3,7';$Row3_Example = '0,12';

Then I compare the SESSION to each DIGIT Value, and Every Row.Im stuck here a bit, maybe use explode, but how can i loop all of them?

My way doesn't work yet and I was wondering if there is an easier way to do this with MySQL?
The problem is the explode of the array I think, I dont know how to explode it into a MySQL statement and loop through it.

PS: I ordered Rudy Limebacks "Simply SQL" today, so I'll get better soon once it arrives

I didn't think so! It will get really slow with tons of entries and that will be a pickle. I'll be reading and highlighting that precious book once it comes in the mail and try to figure something out, for now it's a temporary solution >=)

Obviously LIMIT X wouldn't be good, it still scans a lot of rows and limits me to what Im trying to achieve in pagination. I actually can't comprehend any logical way to scale it with my limited knowledge of SQL at the moment, but will see in due time

I don't totally know if this is what you ment, I haven't tried fiddling with a new table yet as I can't figure a way to do it how you say (but i wrote one below the project one) -- I need the users to be assigned to more than one project if they want.