0

Hi

Im having a hardtime making my query work the way it should be.i'm getting wrong output. basically what im trying to do is a simple user statistic that will show the user inputed data and user processed data base on the date range the user selected.

heres the screenshots for better visualization
1.jpg

and the query for that is.
first Get all the user from the user table

Select Name from user GROUP BY Name ORDER BY Name ASC

then i will loop inside the reservations table for the matching username base on the date range selected

select   
     SDate,
     FoName,
     COUNT( FoName ) AS 'opentrans' 
     From reservations 
     where SDate BETWEEN '" . $from . "'  AND '" . $to. "'
     AND FoName='$ngaran'
     GROUP BY FoName ORDER BY FoName ASC

after getting all the username available on that date range. i will loop inside table trans_logs to get all the proceesed/served transactions on that date range

Select username,status,
      SUM( IF(  status =  'Served', 1, 0 ) ) Served
      from trans_logs
      where datetime
      BETWEEN '" . $from . " 00:00'  AND '" . $to. " 23:59'
      and username='$ngaran' group by username order by username

I know that is not a great approach. but its the only closest thing in getting what i want. but i also tried using diffrent method the problem is that while im getting the correct result that i want i cant find a way to make the presentation of the data same as the original

what im getting using this approach is

2.jpg

and the query is

SELECT DISTINCT FoName, COUNT( FoName ) AS 
                                opentrans 
                                FROM reservations
                                WHERE SDate between
                                '" . $from . "'  AND '" . $to. "'
                                GROUP BY FoName
                                UNION 
                                SELECT DISTINCT  username ,  COUNT(DISTINCT CASE WHEN status = 'Served' THEN  1 END) 'Served'
                                FROM trans_logs
                                WHERE datetime
                                BETWEEN  '" . $from . " 00:00'  AND '" . $to. " 23:59'
                                GROUP BY  username

Any help?

Edited by ehpratah: typo

3
Contributors
6
Replies
53
Views
2 Years
Discussion Span
Last Post by ehpratah
0

Wonder if this will get you the result.

SELECT   
  reservations.SDate,
  reservations.FoName,
  COUNT(reservations.FoName) AS 'opentrans',
  trans_logs.status,
  SUM( IF(  trans_logs.status =  'Served', 1, 0 ) ) Served
FROM reservations,trans_logs
WHERE (reservations.SDate BETWEEN '" . $from . "'  AND '" . $to. "')
  OR (trans_logs.datetime BETWEEN '" . $from . " 00:00'  AND '" . $to. " 23:59')
  AND (trans_logs.username = reservations.FoName)
ORDER BY reservations.FoName
0

Hi LPS! thanks for your for that but unfortunately its not working i am just getting this error message.

Error in Processing Request

Error code: 504

Error text: Gateway Time-out

i also tried using left outer join with no avail.

0

Gateway timeout means the code didnt even get to the server most likely.

Check your connection to your database and retry his code

0

tried it several time already on phpmyadmin with the same error message.

0

Can you export the database related tables as sql and somehow post for us to simulate?

0

yes sure but its a large file so i'll just trim it down.

this is for the table trans_logs for the Date 2015-06-04

CREATE TABLE IF NOT EXISTS `trans_logs` (
  `translogid` int(6) NOT NULL AUTO_INCREMENT,
  `username` varchar(30) NOT NULL,
  `datetime` varchar(100) NOT NULL,
  `ref` varchar(15) NOT NULL,
  `status` varchar(15) NOT NULL,
  PRIMARY KEY (`translogid`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=26598 ;



INSERT INTO `trans_logs` (`translogid`, `username`, `datetime`, `ref`, `status`) VALUES
(26309, 'Ronel Rapadas', '2015-06-04 12:54', '150603029342', 'Ongoing'),
(26310, 'Ronel Rapadas', '2015-06-04 12:55', '150603029342', 'Served'),
(26311, 'KATRINA LEYESA', '2015-06-04 01:58', '150603027A5C', 'Ongoing'),
(26312, 'KATRINA LEYESA', '2015-06-04 02:02', '150603027A5C', 'Served'),
(26313, 'KATRINA LEYESA', '2015-06-04 02:04', '150603028476', 'Ongoing'),
(26314, 'KATRINA LEYESA', '2015-06-04 02:05', '150603028476', 'Served'),
(26315, 'KATRINA LEYESA', '2015-06-04 02:06', '15060302A2D8', 'Ongoing'),
(26316, 'KATRINA LEYESA', '2015-06-04 02:07', '15060302A2D8', 'Served'),
(26317, 'KATRINA LEYESA', '2015-06-04 02:08', '15060302C708', 'Ongoing'),
(26318, 'KATRINA LEYESA', '2015-06-04 02:09', '15060302C708', 'Served'),
(26319, 'KATRINA LEYESA', '2015-06-04 02:11', '15060302AA39', 'Ongoing'),
(26320, 'KATRINA LEYESA', '2015-06-04 02:11', '15060302AA39', 'Served'),
(26321, 'KATRINA LEYESA', '2015-06-04 02:14', '150603023479', 'Ongoing'),
(26322, 'KATRINA LEYESA', '2015-06-04 02:14', '150603023479', 'Served'),
(26323, 'KATRINA LEYESA', '2015-06-04 02:19', '15060302250E', 'Ongoing'),
(26324, 'KATRINA LEYESA', '2015-06-04 02:19', '15060302250E', 'Served'),
(26325, 'KATRINA LEYESA', '2015-06-04 02:29', '15060402CC37', 'Ongoing'),
(26326, 'KATRINA LEYESA', '2015-06-04 02:30', '15060402CC37', 'Served'),
(26327, 'KATRINA LEYESA', '2015-06-04 02:40', '1506040264F6', 'Ongoing'),
(26328, 'KATRINA LEYESA', '2015-06-04 02:42', '1506040264F6', 'Served'),
(26329, 'Ronel Rapadas', '2015-06-04 03:04', '1506040239FE', 'Ongoing'),
(26330, 'Ronel Rapadas', '2015-06-04 03:05', '1506040239FE', 'Served'),
(26331, 'Ronel Rapadas', '2015-06-04 03:06', '150604022566', 'Ongoing'),
(26332, 'Ronel Rapadas', '2015-06-04 03:06', '150604022566', 'Served'),
(26333, 'Mylinor Breis', '2015-06-04 05:36', '150603025529', 'Ongoing'),
(26334, 'Mylinor Breis', '2015-06-04 05:36', '150603025529', 'Served'),
(26335, 'Mylinor Breis', '2015-06-04 05:40', '150603027CD2', 'Ongoing'),
(26336, 'Mylinor Breis', '2015-06-04 05:41', '150603027CD2', 'Served'),
(26337, 'Mylinor Breis', '2015-06-04 05:45', '150604028C57', 'Ongoing'),
(26338, 'Mylinor Breis', '2015-06-04 05:45', '150604028C57', 'Served'),
(26339, 'Mylinor Breis', '2015-06-04 05:50', '15060402D199', 'Ongoing'),
(26340, 'Mylinor Breis', '2015-06-04 05:50', '15060402D199', 'Served'),
(26341, 'Mylinor Breis', '2015-06-04 05:56', '150604026EA4', 'Ongoing'),
(26342, 'Mylinor Breis', '2015-06-04 05:56', '150604026EA4', 'Served'),
(26343, 'Mylinor Breis', '2015-06-04 06:02', '15060402B750', 'Ongoing'),
(26344, 'Mylinor Breis', '2015-06-04 06:03', '15060402B750', 'Served'),
(26345, 'Mylinor Breis', '2015-06-04 06:07', '15060402647C', 'Ongoing'),
(26346, 'Mylinor Breis', '2015-06-04 06:07', '15060402647C', 'Served'),
(26347, 'Mylinor Breis', '2015-06-04 06:16', '15060402B586', 'Ongoing'),
(26348, 'Mylinor Breis', '2015-06-04 06:16', '15060402B586', 'Served'),
(26349, 'Mylinor Breis', '2015-06-04 06:23', '150604022969', 'Ongoing'),
(26350, 'Mylinor Breis', '2015-06-04 06:23', '150604022969', 'Served'),
(26351, 'Mylinor Breis', '2015-06-04 06:31', '150604022C68', 'Ongoing'),
(26352, 'Mylinor Breis', '2015-06-04 06:31', '150604022C68', 'Served'),
(26353, 'Mylinor Breis', '2015-06-04 06:36', '150604025151', 'Ongoing'),
(26354, 'Mylinor Breis', '2015-06-04 06:36', '150604025151', 'Served'),
(26355, 'Mylinor Breis', '2015-06-04 06:38', '15060402B24D', 'Ongoing'),
(26356, 'Mylinor Breis', '2015-06-04 06:39', '15060402B24D', 'Served'),
(26357, 'Mylinor Breis', '2015-06-04 06:42', '150604020F93', 'Ongoing'),
(26358, 'Mylinor Breis', '2015-06-04 06:42', '150604020F93', 'Served'),
(26359, 'Ronel Rapadas', '2015-06-04 06:43', '150603025B7C', 'Ongoing'),
(26360, 'Mylinor Breis', '2015-06-04 06:45', '15060402D7C0', 'Ongoing'),
(26361, 'Mylinor Breis', '2015-06-04 06:45', '15060402D7C0', 'Served'),
(26362, 'Ronel Rapadas', '2015-06-04 06:45', '150603025B7C', 'Served'),
(26363, 'Ronel Rapadas', '2015-06-04 06:51', '15060302264A', 'Ongoing'),
(26364, 'Ronel Rapadas', '2015-06-04 06:54', '15060302264A', 'Served'),
(26365, 'Ronel Rapadas', '2015-06-04 06:58', '15060302E585', 'Ongoing'),
(26366, 'Ronel Rapadas', '2015-06-04 06:59', '15060302E585', 'Served'),
(26367, 'ARIEL SAQUIN', '2015-06-04 07:18', '15060302DEFA', 'Ongoing'),
(26368, 'ARIEL SAQUIN', '2015-06-04 07:20', '15060302DEFA', 'Served'),
(26369, 'Phil Joyce Tatel', '2015-06-04 07:21', '150604026B8F', 'Ongoing'),
(26370, 'Phil Joyce Tatel', '2015-06-04 07:21', '150604026B8F', 'Served'),
(26371, 'ARIEL SAQUIN', '2015-06-04 07:24', '15060302BA03', 'Ongoing'),
(26372, 'ARIEL SAQUIN', '2015-06-04 07:26', '15060302BA03', 'Served'),
(26373, 'ARIEL SAQUIN', '2015-06-04 07:32', '150603022036', 'Served'),
(26374, 'ARIEL SAQUIN', '2015-06-04 07:50', '150604029D30', 'Ongoing'),
(26375, 'ARIEL SAQUIN', '2015-06-04 07:51', '150604029D30', 'Served'),
(26376, 'Phil Joyce Tatel', '2015-06-04 07:51', '1506040276D4', 'Ongoing'),
(26377, 'Phil Joyce Tatel', '2015-06-04 07:52', '1506040276D4', 'Served'),
(26378, 'Phil Joyce Tatel', '2015-06-04 07:54', '15060402B94D', 'Ongoing'),
(26379, 'Phil Joyce Tatel', '2015-06-04 07:54', '15060402B94D', 'Served'),
(26380, 'ARIEL SAQUIN', '2015-06-04 07:57', '150604022BC0', 'Ongoing'),
(26381, 'ARIEL SAQUIN', '2015-06-04 07:57', '150604022BC0', 'Served'),
(26382, 'Phil Joyce Tatel', '2015-06-04 08:09', '150604020D8C', 'Ongoing'),
(26383, 'Phil Joyce Tatel', '2015-06-04 08:10', '150604020D8C', 'Served'),
(26384, 'ARIEL SAQUIN', '2015-06-04 08:13', '15060402E125', 'Ongoing'),
(26385, 'ARIEL SAQUIN', '2015-06-04 08:15', '15060402E125', 'Served'),
(26386, 'ARIEL SAQUIN', '2015-06-04 08:22', '150604022384', 'Ongoing'),
(26387, 'ARIEL SAQUIN', '2015-06-04 08:23', '150604022384', 'Served'),
(26388, 'Phil Joyce Tatel', '2015-06-04 08:38', '150604020817', 'Ongoing'),
(26389, 'Phil Joyce Tatel', '2015-06-04 08:38', '150604020817', 'Served'),
(26390, 'Phil Joyce Tatel', '2015-06-04 08:40', '15060302FD8A', 'Ongoing'),
(26391, 'Phil Joyce Tatel', '2015-06-04 08:41', '15060302FD8A', 'Served'),
(26392, 'Phil Joyce Tatel', '2015-06-04 08:41', '1506040275A0', 'Ongoing'),
(26393, 'Phil Joyce Tatel', '2015-06-04 08:46', '1506040275A0', 'Served'),
(26394, 'Phil Joyce Tatel', '2015-06-04 08:46', '15060202385C', 'Ongoing'),
(26395, 'Len Jimenez', '2015-06-04 08:50', '15060302D41D', 'Ongoing'),
(26396, 'Phil Joyce Tatel', '2015-06-04 08:51', '15060202385C', 'Served'),
(26397, 'Phil Joyce Tatel', '2015-06-04 08:54', '150604029977', 'Ongoing'),
(26398, 'Phil Joyce Tatel', '2015-06-04 08:55', '150604029977', 'Served'),
(26399, 'ARIEL SAQUIN', '2015-06-04 09:04', '150604024AB4', 'Ongoing'),
(26400, 'Phil Joyce Tatel', '2015-06-04 09:16', '150604027F1B', 'Ongoing'),
(26401, 'Phil Joyce Tatel', '2015-06-04 09:16', '150604027F1B', 'Served'),
(26402, 'Phil Joyce Tatel', '2015-06-04 09:22', '150604023AF4', 'Ongoing'),
(26403, 'Phil Joyce Tatel', '2015-06-04 09:23', '150604023AF4', 'Served'),
(26404, 'ARIEL SAQUIN', '2015-06-04 09:25', '150604029513', 'Ongoing'),
(26405, 'Phil Joyce Tatel', '2015-06-04 09:25', '15060402AF8A', 'Ongoing'),
(26406, 'Phil Joyce Tatel', '2015-06-04 09:26', '15060402AF8A', 'Served'),
(26407, 'Phil Joyce Tatel', '2015-06-04 09:28', '15060402B553', 'Ongoing'),
(26408, 'Phil Joyce Tatel', '2015-06-04 09:29', '15060402B553', 'Served'),
(26409, 'Phil Joyce Tatel', '2015-06-04 09:36', '1506040296CA', 'Ongoing'),
(26410, 'Phil Joyce Tatel', '2015-06-04 09:37', '1506040296CA', 'Served'),
(26411, 'ARIEL SAQUIN', '2015-06-04 09:38', '1506040219A8', 'Ongoing'),
(26412, 'Phil Joyce Tatel', '2015-06-04 09:59', '15060402E1EB', 'Ongoing'),
(26413, 'Phil Joyce Tatel', '2015-06-04 10:00', '15060402E1EB', 'Served'),
(26414, 'Phil Joyce Tatel', '2015-06-04 10:04', '150604023AE3', 'Ongoing'),
(26415, 'Phil Joyce Tatel', '2015-06-04 10:04', '150604023AE3', 'Served'),
(26416, 'Phil Joyce Tatel', '2015-06-04 10:11', '15060402B2C7', 'Ongoing'),
(26417, 'Phil Joyce Tatel', '2015-06-04 10:11', '15060402B2C7', 'Served'),
(26418, 'Phil Joyce Tatel', '2015-06-04 10:18', '15060402EC06', 'Ongoing'),
(26419, 'Phil Joyce Tatel', '2015-06-04 10:18', '15060402EC06', 'Served'),
(26420, 'Phil Joyce Tatel', '2015-06-04 10:35', '150604023347', 'Ongoing'),
(26421, 'Phil Joyce Tatel', '2015-06-04 10:35', '150604023347', 'Served'),
(26422, 'Phil Joyce Tatel', '2015-06-04 10:39', '15060402E632', 'Ongoing'),
(26423, 'Phil Joyce Tatel', '2015-06-04 10:40', '15060402E632', 'Served'),
(26424, 'Phil Joyce Tatel', '2015-06-04 10:43', '15060402C908', 'Ongoing'),
(26425, 'ARIEL SAQUIN', '2015-06-04 11:06', '1506040219A8', 'Served'),
(26426, 'ARIEL SAQUIN', '2015-06-04 11:29', '150604024CDC', 'Ongoing'),
(26427, 'ARIEL SAQUIN', '2015-06-04 11:29', '150604024CDC', 'Served'),
(26428, 'ARIEL SAQUIN', '2015-06-04 11:31', '15060402C908', 'Served'),
(26429, 'Phil Joyce Tatel', '2015-06-04 11:34', '150604024792', 'Ongoing'),
(26430, 'Phil Joyce Tatel', '2015-06-04 11:45', '150604024792', 'Served'),
(26431, 'Phil Joyce Tatel', '2015-06-04 12:08', '15060402C933', 'Ongoing'),
(26432, 'Phil Joyce Tatel', '2015-06-04 12:10', '150604021986', 'Ongoing'),
(26433, 'Phil Joyce Tatel', '2015-06-04 12:11', '150604021986', 'Served'),
(26434, 'ARIEL SAQUIN', '2015-06-04 12:40', '150604029513', 'Served'),
(26435, 'ARIEL SAQUIN', '2015-06-04 12:42', '1506040267D5', 'Ongoing'),
(26436, 'ARIEL SAQUIN', '2015-06-04 12:43', '1506040267D5', 'Served'),
(26437, 'Phil Joyce Tatel', '2015-06-04 01:12', '15060402DBD5', 'Ongoing'),
(26438, 'Phil Joyce Tatel', '2015-06-04 01:42', '15060402BCB9', 'Ongoing'),
(26439, 'Phil Joyce Tatel', '2015-06-04 01:42', '15060402BCB9', 'Served'),
(26440, 'Phil Joyce Tatel', '2015-06-04 01:47', '15060402881F', 'Ongoing'),
(26441, 'Phil Joyce Tatel', '2015-06-04 01:48', '15060402881F', 'Served'),
(26442, 'Phil Joyce Tatel', '2015-06-04 01:57', '15060402D6B4', 'Ongoing'),
(26443, 'Phil Joyce Tatel', '2015-06-04 02:34', '15060402B3DE', 'Ongoing'),
(26444, 'Phil Joyce Tatel', '2015-06-04 02:34', '1506040261B2', 'Ongoing'),
(26445, 'Phil Joyce Tatel', '2015-06-04 02:35', '150604028B59', 'Ongoing'),
(26446, 'Phil Joyce Tatel', '2015-06-04 02:36', '150604022D05', 'Ongoing'),
(26447, 'Phil Joyce Tatel', '2015-06-04 02:37', '150604022D05', 'Served'),
(26448, 'Phil Joyce Tatel', '2015-06-04 03:20', '15060402863E', 'Ongoing'),
(26449, 'Phil Joyce Tatel', '2015-06-04 03:20', '15060402863E', 'Served'),
(26450, 'Phil Joyce Tatel', '2015-06-04 03:21', '150604028B59', 'Served'),
(26451, 'Phil Joyce Tatel', '2015-06-04 03:23', '1506040261B2', 'Served'),
(26452, 'Phil Joyce Tatel', '2015-06-04 03:23', '15060402B3DE', 'Served'),
(26453, 'Phil Joyce Tatel', '2015-06-04 03:27', '15060402DBD5', 'Served'),
(26454, 'Phil Joyce Tatel', '2015-06-04 03:28', '15060402D6B4', 'Served'),
(26455, 'Phil Joyce Tatel', '2015-06-04 03:33', '15060402A914', 'Ongoing'),
(26456, 'Phil Joyce Tatel', '2015-06-04 03:33', '15060402A914', 'Served'),
(26457, 'Phil Joyce Tatel', '2015-06-04 03:38', '15060402DE93', 'Ongoing'),
(26458, 'Phil Joyce Tatel', '2015-06-04 03:38', '15060402DE93', 'Served'),
(26459, 'Phil Joyce Tatel', '2015-06-04 03:45', '1506040225EB', 'Ongoing'),
(26460, 'Phil Joyce Tatel', '2015-06-04 03:46', '1506040225EB', 'Served'),
(26461, 'Phil Joyce Tatel', '2015-06-04 04:03', '1506040215DA', 'Ongoing'),
(26462, 'Phil Joyce Tatel', '2015-06-04 04:04', '1506040215DA', 'Served'),
(26463, 'Phil Joyce Tatel', '2015-06-04 04:07', '150604023BBC', 'Ongoing'),
(26464, 'Phil Joyce Tatel', '2015-06-04 04:07', '150604023BBC', 'Served'),
(26465, 'Phil Joyce Tatel', '2015-06-04 04:09', '1506040247C6', 'Ongoing'),
(26466, 'Phil Joyce Tatel', '2015-06-04 04:10', '1506040247C6', 'Served'),
(26467, 'Phil Joyce Tatel', '2015-06-04 04:15', '15060402EA85', 'Ongoing'),
(26468, 'Phil Joyce Tatel', '2015-06-04 04:21', '15060402EA85', 'Served'),
(26469, 'Phil Joyce Tatel', '2015-06-04 04:24', '15060402C648', 'Ongoing'),
(26470, 'Phil Joyce Tatel', '2015-06-04 04:25', '15060402C648', 'Served'),
(26471, 'Phil Joyce Tatel', '2015-06-04 04:27', '150604029913', 'Ongoing'),
(26472, 'Phil Joyce Tatel', '2015-06-04 04:28', '150604029913', 'Served'),
(26473, 'Phil Joyce Tatel', '2015-06-04 04:31', '150604029560', 'Ongoing'),
(26474, 'Phil Joyce Tatel', '2015-06-04 04:33', '150604025F06', 'Ongoing'),
(26475, 'Phil Joyce Tatel', '2015-06-04 04:35', '15060402255F', 'Ongoing'),
(26476, 'Phil Joyce Tatel', '2015-06-04 04:35', '15060402255F', 'Served'),
(26477, 'Phil Joyce Tatel', '2015-06-04 04:38', '15060402C992', 'Ongoing'),
(26478, 'Phil Joyce Tatel', '2015-06-04 04:39', '15060402C992', 'Served'),
(26479, 'Phil Joyce Tatel', '2015-06-04 04:41', '1506040202FC', 'Ongoing'),
(26480, 'Phil Joyce Tatel', '2015-06-04 04:41', '1506040202FC', 'Served'),
(26481, 'Phil Joyce Tatel', '2015-06-04 04:43', '15060402EA0C', 'Ongoing'),
(26482, 'Phil Joyce Tatel', '2015-06-04 04:43', '15060402EA0C', 'Served'),
(26483, 'Phil Joyce Tatel', '2015-06-04 04:46', '15060402CD13', 'Ongoing'),
(26484, 'Phil Joyce Tatel', '2015-06-04 04:46', '15060402CD13', 'Served'),
(26485, 'Phil Joyce Tatel', '2015-06-04 04:49', '150604029560', 'Served'),
(26486, 'Phil Joyce Tatel', '2015-06-04 04:50', '150604025F06', 'Served'),
(26487, 'ARIEL SAQUIN', '2015-06-04 05:11', '1506040261E4', 'Ongoing'),
(26488, 'Phil Joyce Tatel', '2015-06-04 05:11', '150604027C57', 'Ongoing'),
(26489, 'ARIEL SAQUIN', '2015-06-04 05:12', '1506040261E4', 'Served'),
(26490, 'Phil Joyce Tatel', '2015-06-04 05:13', '150604027C57', 'Served'),
(26491, 'ARIEL SAQUIN', '2015-06-04 05:17', '15060402F0EE', 'Ongoing'),
(26492, 'ARIEL SAQUIN', '2015-06-04 05:19', '15060402F0EE', 'Served'),
(26493, 'Phil Joyce Tatel', '2015-06-04 05:28', '150604029E16', 'Ongoing'),
(26494, 'Phil Joyce Tatel', '2015-06-04 05:28', '150604029E16', 'Served'),
(26495, 'ARIEL SAQUIN', '2015-06-04 05:32', '15060402CA75', 'Ongoing'),
(26496, 'ARIEL SAQUIN', '2015-06-04 05:33', '15060402CA75', 'Served'),
(26497, 'ARIEL SAQUIN', '2015-06-04 05:34', '15060402B427', 'Ongoing'),
(26498, 'ARIEL SAQUIN', '2015-06-04 05:35', '15060402B427', 'Served'),
(26499, 'Phil Joyce Tatel', '2015-06-04 05:41', '1506040238F5', 'Ongoing'),
(26500, 'Phil Joyce Tatel', '2015-06-04 05:42', '1506040238F5', 'Served'),
(26501, 'ARIEL SAQUIN', '2015-06-04 05:42', '150604024AB4', 'Served'),
(26502, 'Phil Joyce Tatel', '2015-06-04 06:07', '150604023D5F', 'Ongoing'),
(26503, 'Phil Joyce Tatel', '2015-06-04 06:07', '150604023D5F', 'Served'),
(26504, 'ARIEL SAQUIN', '2015-06-04 06:56', '15060402DD2E', 'Ongoing'),
(26505, 'ARIEL SAQUIN', '2015-06-04 06:56', '15060402DD2E', 'Served'),
(26506, 'Kristine Dela Cruz', '2015-06-04 07:52', '15060402DE84', 'Ongoing'),
(26507, 'Kristine Dela Cruz', '2015-06-04 07:52', '15060402DE84', 'Served'),
(26508, 'Kristine Dela Cruz', '2015-06-04 07:54', '1506040202D4', 'Ongoing'),
(26509, 'Kristine Dela Cruz', '2015-06-04 07:55', '1506040202D4', 'Served'),
(26510, 'Kristine Dela Cruz', '2015-06-04 07:58', '15060402A330', 'Ongoing'),
(26511, 'Kristine Dela Cruz', '2015-06-04 07:58', '15060402A330', 'Served'),
(26512, 'Kristine Dela Cruz', '2015-06-04 08:05', '15060402B005', 'Ongoing'),
(26513, 'Kristine Dela Cruz', '2015-06-04 08:05', '15060402B005', 'Served'),
(26514, 'Kristine Dela Cruz', '2015-06-04 09:31', '150604023FE6', 'Ongoing'),
(26515, 'Kristine Dela Cruz', '2015-06-04 09:31', '150604023FE6', 'Served'),
(26516, 'Kristine Dela Cruz', '2015-06-04 09:32', '15060402C42D', 'Ongoing'),
(26517, 'Kristine Dela Cruz', '2015-06-04 09:33', '15060402C42D', 'Served'),
(26518, 'Kristine Dela Cruz', '2015-06-04 09:34', '150604022F93', 'Ongoing'),
(26519, 'Kristine Dela Cruz', '2015-06-04 09:35', '150604022F93', 'Served'),
(26520, 'Kristine Dela Cruz', '2015-06-04 09:36', '1506040297EF', 'Ongoing'),
(26521, 'Kristine Dela Cruz', '2015-06-04 09:36', '1506040297EF', 'Served'),
(26522, 'Kristine Dela Cruz', '2015-06-04 09:38', '15060402EE9C', 'Ongoing'),
(26523, 'Kristine Dela Cruz', '2015-06-04 09:39', '15060402EE9C', 'Served'),
(26524, 'Kristine Dela Cruz', '2015-06-04 09:39', '150604021763', 'Ongoing'),
(26525, 'Kristine Dela Cruz', '2015-06-04 09:40', '150604021763', 'Served'),
(26526, 'Kristine Dela Cruz', '2015-06-04 09:41', '150604021508', 'Ongoing'),
(26527, 'Kristine Dela Cruz', '2015-06-04 09:42', '150604021508', 'Served'),
(26528, 'Kristine Dela Cruz', '2015-06-04 09:43', '15060402D2F0', 'Ongoing'),
(26529, 'Kristine Dela Cruz', '2015-06-04 09:43', '15060402D2F0', 'Served'),
(26530, 'Kristine Dela Cruz', '2015-06-04 09:46', '15060402ECE8', 'Ongoing'),
(26531, 'Kristine Dela Cruz', '2015-06-04 09:47', '15060402ECE8', 'Served'),
(26532, 'Ronel Rapadas', '2015-06-04 10:40', '150603027CD3', 'Ongoing'),
(26533, 'Ronel Rapadas', '2015-06-04 10:41', '150603027CD3', 'Served'),
(26534, 'Ronel Rapadas', '2015-06-04 10:50', '150604024F1C', 'Ongoing'),
(26535, 'Ronel Rapadas', '2015-06-04 10:50', '150604024F1C', 'Served'),
(26536, 'Kristine Dela Cruz', '2015-06-04 10:56', '15060402B2A8', 'Ongoing'),
(26537, 'Kristine Dela Cruz', '2015-06-04 10:57', '15060402B2A8', 'Served'),
(26538, 'Kristine Dela Cruz', '2015-06-04 10:58', '15060402B30C', 'Ongoing'),
(26539, 'Kristine Dela Cruz', '2015-06-04 10:59', '15060402B30C', 'Served'),
(26540, 'Kristine Dela Cruz', '2015-06-04 11:04', '1506040240C5', 'Ongoing'),
(26541, 'Kristine Dela Cruz', '2015-06-04 11:04', '1506040240C5', 'Served'),
(26542, 'Kristine Dela Cruz', '2015-06-04 11:06', '150604026FBE', 'Ongoing'),
(26543, 'Kristine Dela Cruz', '2015-06-04 11:07', '150604026FBE', 'Served'),
(26544, 'Ronel Rapadas', '2015-06-04 11:14', '1506040265ED', 'Ongoing'),
(26545, 'Ronel Rapadas', '2015-06-04 11:14', '1506040265ED', 'Served'),
(26546, 'Ronel Rapadas', '2015-06-04 11:17', '1506040253F6', 'Ongoing'),
(26547, 'Ronel Rapadas', '2015-06-04 11:24', '1506040253F6', 'Served');

and for the table reservations

CREATE TABLE IF NOT EXISTS `reservations` (
  `Id` int(20) NOT NULL AUTO_INCREMENT,
  `Ref` varchar(20) NOT NULL,
  `FoName` varchar(20) NOT NULL,
  `SDate` date NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Ref` (`Ref`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=18961 ;



INSERT INTO `reservations` (`Id`, `Ref`, `FoName`, `SDate`) VALUES
(18628, '15060202385C', 'Len Jimenez', '2015-06-04'),
(18710, '150603027CD2', 'Ronel Rapadas', '2015-06-04'),
(18713, '15060302FD8A', 'Ronel Rapadas', '2015-06-04'),
(18764, '150603025529', 'Joel Flores', '2015-06-04'),
(18790, '15060302D769', 'Joel Flores', '2015-06-04'),
(18792, '150603027CD3', 'Joel Flores', '2015-06-04'),
(18809, '1506040239FE', 'KATRINA LEYESA', '2015-06-04'),
(18810, '150604022566', 'KATRINA LEYESA', '2015-06-04'),
(18811, '15060402CC37', 'KATRINA LEYESA', '2015-06-04'),
(18812, '1506040264F6', 'KATRINA LEYESA', '2015-06-04'),
(18814, '15060402EC06', 'Ronel Rapadas', '2015-06-04'),
(18815, '150604025333', 'Ronel Rapadas', '2015-06-04'),
(18816, '150604021228', 'Ronel Rapadas', '2015-06-04'),
(18818, '1506040276D4', 'Ronel Rapadas', '2015-06-04'),
(18819, '150604022384', 'Ronel Rapadas', '2015-06-04'),
(18820, '15060402E125', 'Ronel Rapadas', '2015-06-04'),
(18821, '15060402C933', 'Ronel Rapadas', '2015-06-04'),
(18822, '1506040275A0', 'Ronel Rapadas', '2015-06-04'),
(18823, '15060402A330', 'Ronel Rapadas', '2015-06-04'),
(18824, '150604020D54', 'Ronel Rapadas', '2015-06-04'),
(18825, '150604026220', 'Ronel Rapadas', '2015-06-04'),
(18826, '150604028C57', 'Mylinor Breis', '2015-06-04'),
(18827, '15060402D199', 'Mylinor Breis', '2015-06-04'),
(18828, '150604026EA4', 'Mylinor Breis', '2015-06-04'),
(18829, '15060402B750', 'Mylinor Breis', '2015-06-04'),
(18830, '15060402647C', 'Mylinor Breis', '2015-06-04'),
(18831, '15060402B586', 'Mylinor Breis', '2015-06-04'),
(18832, '150604022969', 'Mylinor Breis', '2015-06-04'),
(18833, '150604022C68', 'Mylinor Breis', '2015-06-04'),
(18834, '150604025151', 'Mylinor Breis', '2015-06-04'),
(18835, '15060402B24D', 'Mylinor Breis', '2015-06-04'),
(18836, '150604020F93', 'Mylinor Breis', '2015-06-04'),
(18837, '15060402D7C0', 'Mylinor Breis', '2015-06-04'),
(18838, '15060402C908', 'ARIEL SAQUIN', '2015-06-04'),
(18839, '150604026B8F', 'Phil Joyce Tatel', '2015-06-04'),
(18840, '150604029D30', 'ARIEL SAQUIN', '2015-06-04'),
(18841, '150604022BC0', 'ARIEL SAQUIN', '2015-06-04'),
(18842, '15060402B94D', 'Phil Joyce Tatel', '2015-06-04'),
(18843, '150604020D8C', 'Phil Joyce Tatel', '2015-06-04'),
(18844, '150604020817', 'Phil Joyce Tatel', '2015-06-04'),
(18845, '150604029977', 'Phil Joyce Tatel', '2015-06-04'),
(18846, '150604024AB4', 'ARIEL SAQUIN', '2015-06-04'),
(18847, '150604029513', 'ARIEL SAQUIN', '2015-06-04'),
(18848, '150604027F1B', 'Phil Joyce Tatel', '2015-06-04'),
(18849, '150604023AF4', 'Phil Joyce Tatel', '2015-06-04'),
(18850, '15060402AF8A', 'Phil Joyce Tatel', '2015-06-04'),
(18851, '15060402B553', 'Phil Joyce Tatel', '2015-06-04'),
(18852, '150604021986', 'Phil Joyce Tatel', '2015-06-04'),
(18853, '1506040296CA', 'Phil Joyce Tatel', '2015-06-04'),
(18854, '1506040219A8', 'ARIEL SAQUIN', '2015-06-04'),
(18855, '15060402E1EB', 'Phil Joyce Tatel', '2015-06-04'),
(18856, '150604023AE3', 'Phil Joyce Tatel', '2015-06-04'),
(18857, '15060402B2C7', 'Phil Joyce Tatel', '2015-06-04'),
(18858, '150604023347', 'Phil Joyce Tatel', '2015-06-04'),
(18859, '15060402E632', 'Phil Joyce Tatel', '2015-06-04'),
(18860, '15060402A914', 'ARIEL SAQUIN', '2015-06-04'),
(18861, '150604024CDC', 'ARIEL SAQUIN', '2015-06-04'),
(18862, '150604024792', 'Phil Joyce Tatel', '2015-06-04'),
(18863, '15060402F0EE', 'ARIEL SAQUIN', '2015-06-04'),
(18864, '1506040267D5', 'ARIEL SAQUIN', '2015-06-04'),
(18865, '15060402863E', 'Phil Joyce Tatel', '2015-06-04'),
(18866, '15060402EA0C', 'Phil Joyce Tatel', '2015-06-04'),
(18867, '1506040240C5', 'Phil Joyce Tatel', '2015-06-04'),
(18868, '15060402BCB9', 'Phil Joyce Tatel', '2015-06-04'),
(18869, '15060402DBD5', 'Phil Joyce Tatel', '2015-06-04'),
(18870, '15060402D6B4', 'Phil Joyce Tatel', '2015-06-04'),
(18871, '15060402B3DE', 'Phil Joyce Tatel', '2015-06-04'),
(18872, '150604028B59', 'Phil Joyce Tatel', '2015-06-04'),
(18873, '1506040261B2', 'Phil Joyce Tatel', '2015-06-04'),
(18874, '150604029560', 'Phil Joyce Tatel', '2015-06-04'),
(18875, '15060402D2F0', 'Phil Joyce Tatel', '2015-06-04'),
(18876, '150604022D05', 'Phil Joyce Tatel', '2015-06-04'),
(18877, '15060402DE93', 'Phil Joyce Tatel', '2015-06-04'),
(18878, '15060402881F', 'Phil Joyce Tatel', '2015-06-04'),
(18879, '150604023D5F', 'Phil Joyce Tatel', '2015-06-04'),
(18880, '1506040225EB', 'Phil Joyce Tatel', '2015-06-04'),
(18881, '1506040215DA', 'Phil Joyce Tatel', '2015-06-04'),
(18882, '150604023BBC', 'Phil Joyce Tatel', '2015-06-04'),
(18883, '1506040247C6', 'Phil Joyce Tatel', '2015-06-04'),
(18884, '15060402EA85', 'Phil Joyce Tatel', '2015-06-04'),
(18885, '15060402C648', 'Phil Joyce Tatel', '2015-06-04'),
(18886, '150604029913', 'Phil Joyce Tatel', '2015-06-04'),
(18887, '150604025F06', 'Phil Joyce Tatel', '2015-06-04'),
(18888, '15060402255F', 'Phil Joyce Tatel', '2015-06-04'),
(18889, '15060402C992', 'Phil Joyce Tatel', '2015-06-04'),
(18890, '1506040202FC', 'Phil Joyce Tatel', '2015-06-04'),
(18891, '15060402CD13', 'Phil Joyce Tatel', '2015-06-04'),
(18892, '1506040261E4', 'ARIEL SAQUIN', '2015-06-04'),
(18893, '150604027C57', 'Phil Joyce Tatel', '2015-06-04'),
(18894, '15060402CA75', 'ARIEL SAQUIN', '2015-06-04'),
(18895, '15060402B427', 'ARIEL SAQUIN', '2015-06-04'),
(18896, '150604029E16', 'Phil Joyce Tatel', '2015-06-04'),
(18897, '1506040238F5', 'Phil Joyce Tatel', '2015-06-04'),
(18898, '1506040265ED', 'ARIEL SAQUIN', '2015-06-04'),
(18899, '15060402DD2E', 'ARIEL SAQUIN', '2015-06-04'),
(18900, '150604024F1C', 'Ronel Rapadas', '2015-06-04'),
(18901, '15060402856F', 'Kristine Dela Cruz', '2015-06-04'),
(18903, '15060402DE84', 'Kristine Dela Cruz', '2015-06-04'),
(18904, '1506040202D4', 'Kristine Dela Cruz', '2015-06-04'),
(18905, '15060402B005', 'Kristine Dela Cruz', '2015-06-04'),
(18906, '15060402ECE8', 'Kristine Dela Cruz', '2015-06-04'),
(18907, '150604021508', 'Kristine Dela Cruz', '2015-06-04'),
(18908, '150604021763', 'Kristine Dela Cruz', '2015-06-04'),
(18909, '150604023FE6', 'Kristine Dela Cruz', '2015-06-04'),
(18910, '15060402C42D', 'Kristine Dela Cruz', '2015-06-04'),
(18911, '150604022F93', 'Kristine Dela Cruz', '2015-06-04'),
(18912, '1506040297EF', 'Kristine Dela Cruz', '2015-06-04'),
(18913, '15060402EE9C', 'Kristine Dela Cruz', '2015-06-04'),
(18914, '1506040253F6', 'ARIEL SAQUIN', '2015-06-04'),
(18915, '1506040263DD', 'Kristine Dela Cruz', '2015-06-04'),
(18917, '15060402707D', 'Ronel Rapadas', '2015-06-04'),
(18919, '15060402B2A8', 'Kristine Dela Cruz', '2015-06-04'),
(18920, '15060402B30C', 'Kristine Dela Cruz', '2015-06-04'),
(18921, '150604026FBE', 'Kristine Dela Cruz', '2015-06-04'),
(18923, '150604025DEE', 'Kristine Dela Cruz', '2015-06-04');
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.