Misr
Misr

Reputation: 53

Mysql table records are displayed in a crooked manner

I have created a table in MySQL but when I display the table, some records are displayed in a crooked manner.

Here's the table displayed:

select * from air_passenger_profile;

+------------+----------+------------+-----------+---------------------------------+---------------+---------------------+
| profile_id | password | first_name | last_name | address                         | mobile_number | email_id            |
+------------+----------+------------+-----------+---------------------------------+---------------+---------------------+
| PFL001     | PFL001   | LATHA      | SANKAR    | 123  BROAD  CROSS ST,CHENNAI-48 |    9876543210 |  [email protected]    |
| PFL002     |  PFL002  |  ARUN      |  PRAKASH  |  768  2ND STREET,BENGALURU-20   |    8094564243 | [email protected]        |
| PFL003     |  PFL003  | AMIT       |  VIKARAM  |  43 5TH STREET,KOCHI-84         |    9497996990 | [email protected]        |
| PFL004     |  PFL004  |  AARTHI    |  RAMESH   |  343 6TH STREET,HYDERABAD-76    |    9595652530 |  [email protected]   |
| PFL005     |  PFL005  |  SIVA      |  KUMAR    | 125 8TH STREET,CHENNAI-46       |    9884416986 | [email protected]      |
| PFL006     | PFL006   | RAMESH     |  BABU     |  109 2ND CROSS ST,KOCHI-12      |    9432198760 |  [email protected]   |
| PFL007     | PFL007   | GAYATHRI   |  RAGHU    | 23 2ND CROSS ST,BENGALURU-12    |    8073245678 | [email protected]  |
| PFL008     | PFL008   |  GANESH    | KANNAN    | 45 3RD ST,HYDERABAD-21          |    9375237890 | [email protected]    |
+------------+----------+------------+-----------+---------------------------------+---------------+---------------------+

Upvotes: 0

Views: 87

Answers (1)

Martijn
Martijn

Reputation: 16113

You place it into your database with spaces. At the point where you insert your variables into the databse, you could use PHP's trim() function, or MySQL's, to store it without the spaces.

To correct your current values:

UPDATE air_passenger_profile SET first_name = TRIM(first_name), etc...

Upvotes: 1

Related Questions