This topic is locked

Joining fields together

9/25/2009 6:27:40 AM
PHPRunner General questions
S
swanside author

Hello.
I habe a table called Sites, A table called Jobs and a table called Customers.
When we add a new job in ot the job table, we select the customer using a dropdown. We can then select the sites for that customer.
The site is selected using site_address, but I want to display the full address showing what is in Line1, Line2, Line3, Line4, Line5, Line6, Line7.
I have been looking at this concat thing, but how can I get it to work in my database?

WOuld I have to make a new field in my job table called FullAddress and put something like CONCAT("Line1,Line2....") as FullAddress?

Thanks

Paul

CREATE TABLE IF NOT EXISTS sites (

Customer_Name varchar(500) NOT NULL,

site_address varchar(500) DEFAULT NULL,

LocationId int(255) NOT NULL AUTO_INCREMENT,

Post_Code varchar(20) NOT NULL,

Line1 varchar(100) NOT NULL,

Line2 varchar(100) NOT NULL,

Line3 varchar(100) NOT NULL,

Line4 varchar(100) NOT NULL,

Line5 varchar(100) NOT NULL,

Line6 varchar(100) NOT NULL,

Line7 varchar(100) NOT NULL,

CustomerId int(11) NOT NULL,

DoorCode varchar(20) DEFAULT NULL,

GateCode varchar(20) DEFAULT NULL,

AlarmCode varchar(20) DEFAULT NULL,

ExtraCodes varchar(100) DEFAULT NULL,

PRIMARY KEY (LocationId),

KEY Customer_Name (Customer_Name)

) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1115 ;

J
Jane 9/25/2009

Hi,
use custom expression as display field for this purpose.

Here is just a sample:

concat(Line1, ' ', Line2, ' ', Line3)