Jump to content

Recommended Posts

Posted

I am working on a script that will support a MySQL db, I am currently still learning MySQL. I am about 95% finished with the script but I have "painted myself into a corner."

 

I have written the script to change the "default value" for a table column based the last thing the script has done when it is finished. The problem is, I would like to query the "default value" for the table column early in the script. I cannot find a way to do it. Can anyone help me?

Posted
The SQL query would look something like this:

>SELECT DISTINCT `defaultvalue`
FROM `your_table`
WHERE `recordid` = yourvariable

Thanks, but that does not give me what I want.

 

I actually want to query the table structure not the data in the table.

Posted
I actually want to query the table structure not the data in the table.

Guess my reading comprehension skills could use some work. In this case, I agree that DESCRIBE is the way to go.

Posted
You want the "DESCRIBE" statement.

 

Thanks, that does the trick. This is basically what I came up with.

>$sql = "DESCRIBE tbl_name col_name";

if ( $query = mysql_query($sql) )
if ( $row = mysql_fetch_row($query) ) {
	print $row[4]."<br />\n";
}
 else  print 'Error Reading Database!'."<br />\n";

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