Answer the question
In order to leave comments, you need to log in
How to write a sql query to get order data?
Guys, there is a store database on mysql, I need to pull out (via php) orders from there. Table with orders of the form
ID|ORDER_ID|PRICE|DATE_INSERT|NAME|QUANTITY|PRICE
When I pull out orders, I get this answer
Array
(
[ID] => 14
[ORDER_ID] => 6
[PRICE] => 1259.1000
[DATE_INSERT] => 2015-10-29 11:40:14
[QUANTITY] => 1.0000
[NAME] => Нижнее белье Белая Свобода
)
Array
(
[ID] => 15
[ORDER_ID] => 6
[PRICE] => 2999.0000
[DATE_INSERT] => 2015-10-29 11:40:31
[QUANTITY] => 1.0000
[NAME] => Платье Весенняя Легкость
)
Array
(
[ID] => 16
[ORDER_ID] => 7
[PRICE] => 999.0000
[DATE_INSERT] => 2015-10-29 12:10:39
[QUANTITY] => 1.0000
[NAME] => Домашние Тапочки Любимый Спорт
)
Array
(
[ORDER_ID] => 6
[DATE_INSERT] => 2015-10-29 11:40:31
Array (
[PRICE] => 1259.1000
[QUANTITY] => 1.0000
[NAME] => Платье Весенняя Легкость
)
Array(
[PRICE] => 2999.0000
[QUANTITY] => 1.0000
[NAME] => Нижнее белье Белая Свобода
)
)
$query = mysql_query('SELECT ID,ORDER_ID,PRICE,DATE_INSERT,QUANTITY,NAME FROM `b_sale_basket` WHERE DATE_FORMAT(`DATE_INSERT`,\'%Y%c%e%H%i%s\')>'.mysql_real_escape_string($_GET['date']).'');
Answer the question
In order to leave comments, you need to log in
one request can not collect an array in an array
two solutions:
1. two separate requests, then the assembly of one array, described here: There is a problem for unloading data. What are some ideas?
2. subquery in query
datas = mysql select * from table
foreach(datas as key => data) {
datas[key][subdata] = mysql select * from table where data[id]
}
the first option is preferred
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question