Sunday 15 January 2012

UNION - MySQL vs SQLight -


After

I have the following SQL query:

  to select (from sku to price, price pricelist_98 As a result from union selection sku, price from pricelist_10) where sku = '5,101,863' group by SKU   

I want to get value from pricelist_98 when the specified products are present in there, Otherwise the price from Pricelist_10 should be dynamically expandable with more and different pricelist tables. The first preachers containing the product should be displayed.

When I ask my MySQL server I get the result of the fire. I also have an iPad app with a database structure that is in a SQLight database but here I get a proxylist line 10, though the product is present in pricelist_98.

I am curious about the technical background, in addition to how the query is handled differently, besides, I am looking for a single-query solution that also works in my SQLight database.

Edit Also keep in mind that WHERE is optional I need SELECT to return each product to at least one of the Pricyclist table I queries.

When you group by , the row to return the option is arbitrary - As long as you do not apply any command to SQL, unless you use the ORDER BY here is clearly stated by mentioning the priority:

  Select main.sku, from main.price (select sku, value, 1 to pricelist_98 where is & lt preference; whatever & gt; union selection sku, where price from pricelist_10 preference to 2 & lt; Some & gt;) of temp1 Main JOIN (selection sku, in the form of minute (priority) preference (select sku, from where pricelist_98 is & lt 1st priority; whatever & gt; union selection sku, from 2 priority to pricelist_10 ou & lt ; Which is something & gt;) as temp3 by SKU on temp2 group) as main.sku = temp3.sku and main.preference = temp3.preference   

Also Better to put where section sub-instructors have otherwise merged, instead of merging whole tables before searching the database, (just Theoretically the query optimizer can do this change, but if MySQL or SQLite did so I would be very surprised).



No comments:

Post a Comment