Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: How to use an hardcoded list of values

From: Baron Schwartz <baron(at)xaprb.com>
Date: Wed Sep 26 2007 - 12:03:03 EDT


Hi,

Manuel Vacelet wrote:
> Hi all,
>
> I have a list of values I get from my application and I want to
> generate a record set based on this list (for an INSERT INTO ...
> SELECT).
>
> Today I have sth like:
>
> SELECT 54, item.item_id, mdv.valueInt
> FROM item i, metadata_value mdv
> WHERE mdv.item_id = 20202
> AND mdv.field_id = 54
> AND i.item_id IN (20203,20204,20205,20206,20223,20207,20208);
>
> Is it possible not to make a look-up in 'item' table ?

I'm not sure I understand, but perhaps you want this:

SELECT 54,
    x.item_id,
    (SELECT valueInt FROM metadata_value WHERE mdv.item_id = 20202) AS valueInt
FROM (
    SELECT 20203 AS item_id
    UNION ALL SELECT 20204
    UNION ALL SELECT 20205
    UNION ALL SELECT 20206
    UNION ALL SELECT 20223
    UNION ALL SELECT 20207
    UNION ALL SELECT 20208
) AS x;

I don't think you're gaining anything by doing this though, unless it is extremely expensive to do a lookup in item.

-- 
MySQL General Mailing List
For list archives: 
http://lists.mysql.com/mysql
To unsubscribe:    
http://lists.mysql.com/mysql?unsub=lists@pantek.com
Received on Wed Sep 26 12:04:51 2007

This archive was generated by hypermail 2.1.8 : Sun Oct 07 2007 - 10:12:16 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library