I have a table in a MySQL database that I am running simple SELECT queries on (for quick diagnostics/analysis - since I am not running phpmyadmin on the server - for security reasons).
I would like to be able to truncate the returned data using something like this:
select id, LEFT(full_name, 32), age FROM user
where user is a table that contains the columns id, full_name and age
I tried the above statement and it didn't work. anyone knows how to do this?
[Edit]
Sorry, when I said it dosen't work, I mean mySQL simply returns the STRING "LEFT(full_name, 32)" as an alias for the column 'full_name' and outputs the field value - which in this case, can be as long as 256 chars.
We use the Truncate command to delete the data stored in the table. The working of truncate command is similar to the working of Delete command without a where clause.
MySQL - TRUNCATE() FunctionThis function keeps the specified number of digits after the decimal and removes the remaining.
TRUNCATE TABLE empties a table completely. It requires the DROP privilege. Logically, TRUNCATE TABLE is similar to a DELETE statement that deletes all rows, or a sequence of DROP TABLE and CREATE TABLE statements. To achieve high performance, TRUNCATE TABLE bypasses the DML method of deleting data.
select id, SUBSTRING(full_name,1, 32), age FROM user
Quoting mysql.com:
For all forms of
SUBSTRING()
, the position of the first character in the string from which the substring is to be extracted is reckoned as 1.
select id, SUBSTRING(full_name,1, 32), age FROM user
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With