Jump to content

Need Some Help Searching Mysql


jbradley04

Recommended Posts

I have a question... I am trying to figure out how I can search my database for the next available spot open, and if it is not available then the next available in another row. My example is this....

 

If I have name1, name 2, name3, name4, name5

and the data is joe, jon, tim, null, null

 

Also, this is not always the same... I have many tables like this but some have name1, name 2 while some go up to name10. I need one statement to search any one of these....

 

How can I do a search that says select the open name in that row. If there are no open rows move to next row and check.

 

I was thinking a loop but not sure how that would work.

 

I appreciate the help!

I hope this all makes sense!

Link to comment
Share on other sites

Your database design is bad, making this task about 5 times harder than it needs to be.

 

You should be storing each separate piece of information in its own row in your table. Then the task would be easy, just add a row and if you are trying to limit the number of entires, just count how many of them there are, by getting a count of the matching rows.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.