jhollin1138 Posted March 25, 2006 Posted March 25, 2006 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? Quote
TCH-Tim Posted March 25, 2006 Posted March 25, 2006 The SQL query would look something like this: >SELECT DISTINCT `defaultvalue` FROM `your_table` WHERE `recordid` = yourvariable Quote
jhollin1138 Posted March 25, 2006 Author Posted March 25, 2006 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. Quote
borfast Posted March 25, 2006 Posted March 25, 2006 You want the "DESCRIBE" statement. http://dev.mysql.com/doc/refman/4.1/en/describe.html Quote
TCH-Tim Posted March 25, 2006 Posted March 25, 2006 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. Quote
jhollin1138 Posted March 25, 2006 Author Posted March 25, 2006 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"; Quote
TCH-Tim Posted March 25, 2006 Posted March 25, 2006 Thanks for the update. Glad you got it working. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.