如何查看数据表指定字段的列信息?附SHOW COLUMNS示例
Hey there! Let's work through how to get column details for specific fields in your table. I noticed the SQL query you tried has a small syntax issue—let's fix that up so you get the exact results you're looking for.
The original query uses commas to separate multiple FIELD conditions, which isn't valid syntax for the WHERE clause here. Instead, you can use either OR to chain the conditions, or the IN operator to simplify things (way cleaner when you have multiple fields to check).
Correct Query Using OR
SHOW COLUMNS FROM core_banking_mpesa WHERE FIELD = 'id' OR FIELD = 'LineNo' OR FIELD = 'Comments';
More Concise Query Using IN
SHOW COLUMNS FROM core_banking_mpesa WHERE FIELD IN ('id', 'LineNo', 'Comments');
Either of these queries will return the full column information (like data type, nullability, default values, etc.) for the specific fields you've listed. Perfect for when you only need details on a subset of columns in your table!
内容的提问来源于stack exchange,提问作者Alex Wanjala

