I have the following tables:
CREATE TABLE `orders` (
`ID` varchar(5) NOT NULL,
`IDUserProfile` int(11),
`IDRestaurant` int(11),
`Date` int(11),
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
CREATE TABLE `userprofiles` (
`ID` int(11) NOT NULL auto_increment,
`IDUser` int(11) NOT NULL,
`Name` varchar(64),
`Phone` varchar(64),
`Address` varchar(255),
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
CREATE TABLE `users` (
`ID` int(11) NOT NULL auto_increment,
`Username` varchar(64) NOT NULL,
`Password` varchar(33) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
I need to do the following:
Show all records in table orders
To show the UserPhone
To show the Username
To order the results on base on date (from orders)
If no Username is linked with the order, I should display null in the results. Same with phone.
I would like to do it without nested queries…
Any help will be appreciated.
1 Answer