Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello everyone!
I have got a client and he's got multiple types of addresses (home address, postal address, invoice-address, etc.).
My data looks like this. It is the Client_Adresses table:
Client | Address Type | Address |
Mr. Adams | A | Street 1 |
Mr. Adams | C | Road 2 |
Mr. Adams | D | Lane 5 |
Mr. Smith | B | Lanestreet 3 |
Mr. Smith | C | Mainroad 2 |
Mr. Smith | E | Path 1 |
Mr. Richards | A | Avenue 3 |
Mr. Richards | D | Pathway 7 |
In a different Client-table, I just want to maintain 1 address for each client. Where I make use of an if-statement to figure out which address is the 'default address' to use.
E.g. if client has type A then use type A as default address. Else, if client has type C, use type C as default address. Else, if client has type B, use type B as default address. And so on, and so on.
But I'm trying to figure out how to script this.
Can anyone give me any pointers? What are useful functions?
Thank you so much in advance!
one query. in above sample data one client have both type of address then which type is default address you want to give??
I have a logic in my mind. Some clients have all types of addresses and some only have 1 or 2.
I want to give each client 1 default address, based on the logic I have in my mind:
if(Client has Type A, Type A,
else if(Client has Type C, Type C,
else if(Client has Type B, Type B,
else if(Client has Type E, Type E, Type D))))