Jump to content

Mysql Showing Columns W/ Content


D.Slatk

Recommended Posts

Okay I have been stumped on this one for a while. Some of my columns for this one table have content, and some do not. Is there a simple query you can use to tell this? Something where I can enter the constraints I need, and based off the normal result returned for that, show which columns are not set as null?

 

Basically I want something to "select" everything like this:

 

>SELECT cell_tile FROM cells WHERE cell_x_id >= 0 AND cell_y_id >= 0 AND cell_x_id <= 24 AND cell_y_id <= 24

 

And with that query I want to be able to get which columns from the rows returned had information in them, hopefully the column names being different rows? :)

 

Thanks!

Link to comment
Share on other sites

  • 2 weeks later...

Thank you for offering but I found out I didn't need to do it that way anyways! But I do have another question... say I have a table with one column and 40 rows with the letter "t" in them. But, I want to set each row to either "t1", "t2", "t3", or "t4" - is there any way to do this with a mysql query? It would be nice if there were a mysql function to generate random integers, but I only see one for decimals. :\ Otherwise I could just use something like UDATE table SET column = concat('t',rand(1,4)).

Link to comment
Share on other sites

... say I have a table with one column and 40 rows with the letter "t" in them. But, I want to set each row to either "t1", "t2", "t3", or "t4" - is there any way to do this with a mysql query? It would be nice if there were a mysql function to generate random integers, but I only see one for decimals. :\ Otherwise I could just use something like UDATE table SET column = concat('t',rand(1,4)).

There is not a single MySQL function that does what you want, but you can use a combination of functions. Instead of concat('t',rand(1,4)), you might try this instead: :huh:

>concat('t', truncate(4*rand()+1,0))

Link to comment
Share on other sites

(sorry for the slow reply) Thanks david for that code! It worked excellently!

Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

×
×
  • Create New...