0

I have a query that brings though a list of passenger names, is there a way in which I can set the length of each of these names to equal 10 characters. So even if I have shorter names eg "bob, demarcus, adam and scott" they would display with the shorter names filled by spaces, eg:

bob |demarcus |adam |scott

My Query is:

(SELECT   tb2.journey_dttm as departure, ('8' - tb2.occupancy) AS seats,
(SELECT IF(GROUP_CONCAT(passenger_name SEPARATOR '|') IS NULL, '', GROUP_CONCAT(passenger_name ORDER BY passenger_name SEPARATOR '|')) 
FROM passengers WHERE journey_id = tb2.id ORDER BY passenger_name) AS passengers FROM shuttle AS tb1 LEFT JOIN journey AS tb2 ON  ";
( tb1.id = tb2.shuttle_id ) LEFT JOIN trip_route AS tb3 ON ( tb2.route_id = tb3.id )
WHERE tb1.depart_dttm = '$depart_dttm' ORDER BY tb2.id ASC, tb2.route_id ASC);
3
Contributors
6
Replies
7
Views
8 Years
Discussion Span
Last Post by manojjena1982
0

output into a table, and the width will adjust to the widest name, or set the td widths
tables are still useful for tabular data

0

Hi, it is being output to a table, but all of the passnger names go as a list within a passenger td, is it not possible to do something in the SQL query?

0

Hi, it is being output to a table, but all of the passnger names go as a list within a passenger td, is it not possible to do something in the SQL query?

sql provides the output data (in rows)
formatting is done by your php script & the html css it generates
nest tables,

<tr>
<td>
<table><tr><TD></td></tr></table>
</td>
<td>
<table><tr><TD></td></tr></table>
</td>
0

But my tables are created dynamically by the sql query, so I cannot hardcode in the nested tables, could I perhaps change my seperator from | to a html element that would organise the display?

0

dynamically code the nested tables the same way the code generates the tables.
The code you have makes horizontal lines
one way is to output the sql query

<tr><td>$s</td><td>$s</td><td>$s</td><td>$s</td><td>$s</td></tr>

one way to make vertical lines

<td>%s<br>%s<br>%s<br>%s<br>%s<br>%s<br>%s<br></td>

its your code, mauck around with it :)

0

Hi!
Try this..

create table data2 as select rpad(name,10,' ') as name  from data
select length(name) from data2

here i am creating a table with the select statement to find out the length on other table. So, its coming as 10.

I think it may help you

manoj

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.