Basically, I have a function that exports data to a csv format for excel… I’m trying to have a single query to select all of the sales record within the selected time period, but I need the first column that is queried to come from another table. The current query I have is as follows:
$select = "SELECT `record_date` AS 'Sale Date',
`record_order_number` AS 'Order #',
`record_activity_number` AS 'Activity #',
`record_total_diy_revenue` AS 'Revenue $'
FROM st_entered_records
WHERE `record_user_id` = '$this->user_id' AND
`record_date` BETWEEN '$this->start_date' AND '$this->end_date' ";
Before
`record_date` AS 'Sale Date'
I need it to run a second select to get the users first and last name in format:
"LastName, FirstName"
(user_last_name)", "(user_first_name) from a second table (st_users)
where `user_id` = '$this->user_id'
Any help would be appreciated! 🙂
You could do a join example of one:
Be sure you match the table names and field names I’m sure you already know this 🙂
EDIT:
Stongly advise you do not use MYSQL_*Reason:
This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used.