I want to align a column in my table. In this case 'Title'
mysql> SELECT Titel, KuenstlerName from Bild;
+--------------------------+---------------+
| Title | Artist|
+--------------------------+---------------+
| Drei Musikanten | Picasso |
| Buveuse assoupie | Picasso |
| Die Flöte des Pan | Picasso |
| Paolo als Harlekin | Picasso |
| Die Umarmung | Picasso |
| Sitzende Frau | Picasso |
| Sternennacht | van Gogh |
| Der Park | Klingt |
| Liegender Hund im Schnee | Marc |
| Hauptweg und Nebenwege | Klee |
| Jungfrau im Baum | Klee |
| Das gelbe Haus | Klee |
+--------------------------+---------------+
Is it possible to align the left column to the right, like this:
+--------------------------+---------------+
| Title | Artist |
+--------------------------+---------------+
| Drei Musikanten| Picasso |
| Buveuse assoupie| Picasso |
| Die Flöte des Pan| Picasso |
+--------------------------+---------------+
Thanks for your help!
If your Title
length is 150 then query like this
SELECT LPAD(Titel,150,' ') as Titel , KuenstlerName from Bild;
Check Manual for LPAD
function.
If Titel
is 100 characters, then do this
SELECT
LPAD(Titel, 100, ' '),
...
or
SELECT
RIGHT(CONCAT(REPEAT(' ', 100), Titel), 100),
...
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