My problem is the following:
I got this:
SELECT table_name FROM information_schema.tables WHERE table_schema = 'cr' limit 1;
+------------+
| table_name |
+------------+
| users |
+------------+
and I want to extract the first letter only:
I am trying:
substring(SELECT table_name FROM information_schema.tables WHERE table_schema = 'cr' limit 1,1,1);
You aren't supposed to use SUBSTRING()
on a query, but you can use it on a column, like this:
SELECT SUBSTRING(table_name, 1, 1) FROM information_schema.tables WHERE table_schema = 'cr' limit 1;
You can also use LEFT(table_name, 1)
which is a lot more self-explanatory.
SUBSTRING
should be applied to the table_name
column:
SELECT SUBSTRING(table_name, 1, 1) FROM information_schema.tables WHERE table_schema = 'cr' LIMIT 1;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.