Re: mysql statement [SOLVED]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Got if figured out, needed a sub-select type of query:

mysql>  SELECT *
     -> FROM ( SELECT * FROM `orders`
     -> WHERE `group` = "groupname" )
     -> AS orders UNION SELECT * FROM `orders`
     -> WHERE `ordernum` LIKE "35132"
     -> OR `price` LIKE "35132"
     -> OR `partnum` LIKE "35132"
     -> OR `vendor` LIKE "35132"
     -> OR `purpose` LIKE "35132"
     -> OR `tracking` LIKE "35132"
     -> OR `contact` LIKE "35132"
     -> AND `group` LIKE 'mac'
     -> ORDER BY `ordernum`
     -> LIMIT 0 , 30;

Jas wrote:
> I am looking for some advice on how to achieve something and so far have
> been unable to do what I am looking to do.
> 
> Here is the query I am using:
> mysql>  SELECT *
>     -> FROM `orders`
>     -> WHERE `ordernum` LIKE "35132"
>     -> OR `price` LIKE "35132"
>     -> OR `partnum` LIKE "35132"
>     -> OR `vendor` LIKE "35132"
>     -> OR `purpose` LIKE "35132"
>     -> OR `tracking` LIKE "35132"
>     -> OR `contact` LIKE "35132"
>     -> AND `group` LIKE 'mac'
>     -> ORDER BY `ordernum`
>     -> LIMIT 0 , 30;
> 
> First here is the table structure:
> mysql> describe orders;
> +-------------+--------------+------+-----+---------+----------------+
> | Field       | Type         | Null | Key | Default | Extra          |
> +-------------+--------------+------+-----+---------+----------------+
> | id          | int(255)     | NO   | PRI |         | auto_increment |
> | ordernum    | int(10)      | NO   |     |         |                |
> | date        | varchar(60)  | NO   |     |         |                |
> | time        | varchar(20)  | NO   |     |         |                |
> | group       | varchar(20)  | NO   |     |         |                |
> | quantity    | int(10)      | NO   |     |         |                |
> | description | varchar(255) | NO   |     |         |                |
> | price       | decimal(3,0) | NO   |     |         |                |
> | partnum     | varchar(40)  | NO   |     |         |                |
> | vendor      | varchar(65)  | NO   |     |         |                |
> | purpose     | varchar(255) | NO   |     |         |                |
> | tracking    | varchar(120) | NO   |     |         |                |
> | contact     | varchar(255) | NO   |     |         |                |
> | eta         | varchar(50)  | NO   |     |         |                |
> | department  | varchar(125) | NO   |     |         |                |
> | notes       | varchar(255) | NO   |     |         |                |
> +-------------+--------------+------+-----+---------+----------------+
> 16 rows in set (0.00 sec)
> 
> I am trying to essentially LIMIT all records returned to be limited by
> the `group` field so I can search for records and limit the rows
> returned by that one field.
> 
> Any tips? TIA.
> jas

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux