Re: how to count columns in SQL?
AFAIK, exposing the database schema tables/views is on the todo list for 5.x. Until then you will have to count the # of rows that comes back from describe table. Shawn Green Database Administrator Unimin Corporation - Spruce Pine Monet [EMAIL PROTECTED] wrote on 09/16/2004 03:50:55 PM: Hi, everyone, I have a sql question here, please dont ignore it and help please. I know one can use describe table in mysql to get number of columns. Is there any way to do so in SQL? I have some tables on SQL sever 2000. I use Access 2000 Link table function to link to the server. And I want to count columns not rows since I want to know how many fields in a table. Any advise? Thanks. Monet __ Do you Yahoo!? Yahoo! Mail is new and improved - Check it out! http://promotions.yahoo.com/new_mail -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: how to count columns in SQL?
Kind of klugy, but it works... Using perl or php, do a fetchrow on a table. With any query, i.e. select * from table. Now assign @row to a scalar variable. This will give you the length of the array. The length is the number of columns. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, September 16, 2004 3:18 PM To: Monet Cc: mysql Subject: Re: how to count columns in SQL? AFAIK, exposing the database schema tables/views is on the todo list for 5.x. Until then you will have to count the # of rows that comes back from describe table. Shawn Green Database Administrator Unimin Corporation - Spruce Pine Monet [EMAIL PROTECTED] wrote on 09/16/2004 03:50:55 PM: Hi, everyone, I have a sql question here, please don't ignore it and help please. I know one can use describe table in mysql to get number of columns. Is there any way to do so in SQL? I have some tables on SQL sever 2000. I use Access 2000 Link table function to link to the server. And I want to count columns not rows since I want to know how many fields in a table. Any advise? Thanks. Monet __ Do you Yahoo!? Yahoo! Mail is new and improved - Check it out! http://promotions.yahoo.com/new_mail -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: how to count columns in SQL?
Shawn, Monet: Actually, there is one other approach that works today: you can use the Java DatabaseMetaData interface to see almost every aspect of your data, including the number of columns in a table, the names and datatypes of those columns, the primary keys, and many more things. I tried this in MySQL 4.0.15 last week and it worked fine. I'm not sure if it would work in MySQL 3.x or if any particular version of the JDBC drivers is needed but this is core JDBC functionality so I expect it would work for older JDBC drivers too. Presumably, JDBC has access to the MySQL catalog and can gather up all of this information. Rhino - Original Message - From: [EMAIL PROTECTED] To: Monet [EMAIL PROTECTED] Cc: mysql [EMAIL PROTECTED] Sent: Thursday, September 16, 2004 4:17 PM Subject: Re: how to count columns in SQL? AFAIK, exposing the database schema tables/views is on the todo list for 5.x. Until then you will have to count the # of rows that comes back from describe table. Shawn Green Database Administrator Unimin Corporation - Spruce Pine Monet [EMAIL PROTECTED] wrote on 09/16/2004 03:50:55 PM: Hi, everyone, I have a sql question here, please dont ignore it and help please. I know one can use describe table in mysql to get number of columns. Is there any way to do so in SQL? I have some tables on SQL sever 2000. I use Access 2000 Link table function to link to the server. And I want to count columns not rows since I want to know how many fields in a table. Any advise? Thanks. Monet __ Do you Yahoo!? Yahoo! Mail is new and improved - Check it out! http://promotions.yahoo.com/new_mail -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]