Results 1 to 2 of 2

Thread: Query help

  1. #1
    Join Date
    Dec 2013

    Unanswered: Query help


    I have three tables. One is called "asset" which holds item asset names, one is called "catalog" which just defines catalog list names, and a third called "catalog_asset" which combines the other two and makes it possible to contain assets within the catalog.

    Right now I AM able to execute the following query to determine all of the assets inside of the catalog. This query works!
    select name from asset where id in (select asset_id from catalog_asset where catalog_id='SHOP_1_LIST');

    The result is something like:
    ITEM 1
    ITEM 2
    and so on.

    However, what I now want is kind of reverse be able to query 1 asset (from table 'asset') from and to display the catalog name in which it resides (from table catalog_asset).

    I tried reversing the above query in a way I thought it would work, but it did not work at all...
    select catalog_id from catalog_asset where exists (select name from asset where id = '2740');

    I want the result to show which catalog the asset resides in (can be multiple):

    Basically I can query which assets are residing in a catalog, but I am unable to query an asset to see which catalog it resides in.

    I am currently working on a tool made in php and I need to display the catalog name.

    Can someone help me?

  2. #2
    Join Date
    Dec 2013
    Nevermind, I figured it out.

    Thanks anyway! This forum looks great.

    BTW this query works:
    select catalog_id from catalog_asset where asset_id = (select id from asset where name = 'ITEM_1')

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts