Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to select specifc entries in MySQL/PHP
    primarykey
    data
    text
    <p>I'm dealing with this problem. There is table<code>orders</code>(<code>oid</code>,<code>datetime</code>,<code>quantity</code>,<code>title</code>,<code>username</code>,<code>mid</code>).</p> <p>The table <code>orders</code> is updated from php code as far as the features <code>oid</code>,<code>datetime</code>,<code>quantity</code>,<code>title</code>,<code>username</code> are concerned. The problem is that I want to classify each entry based on both datetime and username so as to gather these entries under an order code in order to make an ordering entry. (I can't think of anything else at the moment). The question is how can I select those entries that are corresponding to the same username and the same date time.</p> <p>For example the if I have 3entries (freddo espresso,latte,freddoccino) belong to the same order procedure (are posted by the same username, tha exact same datetime) and I need to present them to my user as a completed order.</p> <p>Here is the structure of table <code>orders</code>:</p> <pre><code>CREATE TABLE IF NOT EXISTS `orders` ( `oid` INT UNSIGNED NOT NULL AUTO_INCREMENT, `datetime` DATETIME NOT NULL, `quantity` INT NOT NULL, `sum` FLOAT(4,2) NOT NULL, `title` VARCHAR(30) COLLATE utf8_unicode_ci NOT NULL, `username` VARCHAR(30) COLLATE utf8_unicode_ci NOT NULL, `mid` VARCHAR(30) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`oid`), KEY `username`(`username`,`mid`,`title`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=10000; </code></pre> <p>The feature title is foreign key from table <code>products</code>:</p> <pre><code>CREATE TABLE IF NOT EXISTS `products`( `title` VARCHAR(30) COLLATE utf8_unicode_ci NOT NULL, `descr` TEXT(255), `price` FLOAT(4,2) NOT NULL, `popularity` INT NOT NULL, `cname` VARCHAR(20) COLLATE utf8_unicode_ci NOT NULL, `mid` VARCHAR(30) COLLATE utf8_unicode_ci NOT NULL , PRIMARY KEY(`title`), KEY `cname` (`cname`, `mid`) )ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=10000; </code></pre> <p>Sorry If I'm a little uncomprehensive, though I really need some help to come to a conclusion. Any ideas? Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload