Search Results

Search found 9764 results on 391 pages for 'cross join'.

Page 36/391 | < Previous Page | 32 33 34 35 36 37 38 39 40 41 42 43  | Next Page >

  • Advanced SQL query with lots of joins

    - by lund.mikkel
    Hey fellow programmers Okay, first let me say that this is a hard one. I know the presentation may be a little long. But I how you'll bare with me and help me through anyway :D So I'm developing on an advanced search for bicycles. I've got a lot of tables I need to join to find all, let's say, red and brown bikes. One bike may come in more then one color! I've made this query for now: SELECT DISTINCT p.products_id, #simple product id products_name, #product name products_attributes_id, #color id pov.products_options_values_name #color name FROM products p LEFT JOIN products_description pd ON p.products_id = pd.products_id INNER JOIN products_attributes pa ON pa.products_id = p.products_id LEFT JOIN products_options_values pov ON pov.products_options_values_id = pa.options_values_id LEFT JOIN products_options_search pos ON pov.products_options_values_id = pos.products_options_values_id WHERE pos.products_options_search_id = 4 #code for red OR pos.products_options_search_id = 5 #code for brown My first concern is the many joins. The Products table mainly holds product id and it's image and the Products Description table holds more descriptive info such as name (and product ID of course). I then have the Products Options Values table which holds all the colors and their IDs. Products Options Search is containing the color IDs along with a color group ID (products_options_search_id). Red has the color group code 4 (brown is 5). The products and colors have a many-to-many relationship managed inside Products Attributes. So my question is first of all: Is it okay to make so many joins? Is i hurting the performance? Second: If a bike comes in both red and brown, it'll show up twice even though I use SELECT DISTINCT. Think this is because of the INNER JOIN. Is this possible to avoid and do I have to remove the doubles in my PHP code? Third: Bikes can be double colored (i.e. black and blue). This means that there are two rows for that bike. One where it says the color is black and one where is says its blue. (See second question). But if I replace the OR in the WHERE clause it removes both rows, because none of them fulfill the conditions - only the product. What is the workaround for that? I really hope you will and can help me. I'm a little desperate right now :D Regards Mikkel Lund

    Read the article

  • *Right* outer join in LINQ

    - by Rap
    Is it safe to say that there is no such thing as a right outer join in LINQ? I know to effectively create one, you'd just swap the tables in a left outer join. But can you apply the DefaultIfEmpty() method to the table on the left side of the equijoin to make it a right outer join?

    Read the article

  • Using 'in' in Join

    - by Ruslan
    i have two selects a & b and i join them like: select * from ( select n.id_b || ',' || s.id_b ids, n.name, s.surname from names n, surnames s where n.id_a = s.id_a ) a left join ( select sn.id, sn.second_name ) b on b.id in (a.ids) in this case join doesn't work :( The problem is in b.id in (a.ids). But why if it looks like 12 in (12,24) and no result :(

    Read the article

  • SQL 2 INNER JOINS with 3 tables

    - by Jelmer Holtes
    I've a question about a SQL query.. I'm building a prototype webshop in ASP.NET Visual Studio. Now I'm looking for a solution to view my products. I've build a database in MS Access, it consists of multiple tables. The tables which are important for my question are: Product Productfoto Foto Below you'll see the relations between the tables For me it is important to get three datatypes: Product title, price and image. The product title, and the price are in the Product table. The images are in the Foto table. Because a product can have more than one picture, there is a N - M relation between them. So I've to split it up, I did it in the Productfoto table. So the connection between them is: product.artikelnummer -> productfoto.artikelnummer productfoto.foto_id -> foto.foto_id Then I can read the filename (in the database: foto.bestandnaam) I've created the first inner join, and tested it in Access, this works: SELECT titel, prijs, foto_id FROM Product INNER JOIN Productfoto ON product.artikelnummer = productfoto.artikelnummer But I need another INNER JOIN, how could I create that? I guess something like this (this one will give me an error) SELECT titel, prijs, bestandnaam FROM Product (( INNER JOIN Productfoto ON product.artikelnummer = productfoto.artikkelnummer ) INNER JOIN foto ON productfoto.foto_id = foto.foto_id) Can anyone help me?

    Read the article

  • Nested joins hide table names

    - by Sergio
    Hi: I have three tables: Suppliers, Parts and Types. I need to join all of them while discriminating columns with the same name (say, "id") in the three tables. I would like to successfully run this query: CREATE VIEW Everything AS SELECT Suppliers.name as supplier, Parts.id, Parts.description, Types.typedesc as type FROM Suppliers JOIN (Parts JOIN Types ON Parts.type_id = Types.id) ON Suppliers.id = Parts.supplier_id; My DBMS (sqlite) complains that "there is not such a column (Parts.id)". I guess it forgets table names once the JOIN is done but then how can I refer to the column id that belongs to the table Parts?

    Read the article

  • how to remove repeated record's from results linq to sql

    - by Sadegh
    hi, i want to remove repeated record's from results but distinct don't do this for me! why??? var results = (from words in _Xplorium.Words join wordFiles in _Xplorium.WordFiles on words.WordId equals wordFiles.WordId join files in _Xplorium.Files on wordFiles.FileId equals files.FileId join urls in _Xplorium.Urls on files.UrlId equals urls.UrlId where files.Title.Contains(query) || files.Description.Contains(query) orderby wordFiles.Count descending select new SearchResultItem() { Title = files.Title, Url = urls.Address, Count = wordFiles.Count, CrawledOn = files.CrawledOn, Description = files.Description, Lenght = files.Lenght, UniqueKey = words.WordId + "-" + files.FileId + "-" + urls.UrlId }).Distinct();

    Read the article

  • More efficient left join of big table

    - by Zeus
    Hello, I have the following (simplified) query select P.peopleID, P.peopleName, ED.DataNumber from peopleTable P left outer join ( select PE.peopleID, PE.DataNumber from formElements FE inner join peopleExtra PE on PE.ElementID = FE.FormElementID where FE.FormComponentID = 42 ) ED on ED.peopleID = P.peopleID Without the sub-query this procedure takes ~7 seconds, but with it, it takes about 3minutes. Given that table peopleExtra is rather large, is there a more efficient way to do that join (short of restructuring the DB) ?

    Read the article

  • Thread sleep and thread join.

    - by Dhruv Gairola
    hi guys, if i put a thread to sleep in a loop, netbeans gives me a caution saying Invoking Thread.sleep in loop can cause performance problems. However, if i were to replace the sleep with join, no such caution is given. Both versions compile and work fine tho. My code is below (check the last few lines for "Thread.sleep() vs t.join()"). public class Test{ //Display a message, preceded by the name of the current thread static void threadMessage(String message) { String threadName = Thread.currentThread().getName(); System.out.format("%s: %s%n", threadName, message); } private static class MessageLoop implements Runnable { public void run() { String importantInfo[] = { "Mares eat oats", "Does eat oats", "Little lambs eat ivy", "A kid will eat ivy too" }; try { for (int i = 0; i < importantInfo.length; i++) { //Pause for 4 seconds Thread.sleep(4000); //Print a message threadMessage(importantInfo[i]); } } catch (InterruptedException e) { threadMessage("I wasn't done!"); } } } public static void main(String args[]) throws InterruptedException { //Delay, in milliseconds before we interrupt MessageLoop //thread (default one hour). long patience = 1000 * 60 * 60; //If command line argument present, gives patience in seconds. if (args.length > 0) { try { patience = Long.parseLong(args[0]) * 1000; } catch (NumberFormatException e) { System.err.println("Argument must be an integer."); System.exit(1); } } threadMessage("Starting MessageLoop thread"); long startTime = System.currentTimeMillis(); Thread t = new Thread(new MessageLoop()); t.start(); threadMessage("Waiting for MessageLoop thread to finish"); //loop until MessageLoop thread exits while (t.isAlive()) { threadMessage("Still waiting..."); //Wait maximum of 1 second for MessageLoop thread to //finish. /*******LOOK HERE**********************/ Thread.sleep(1000);//issues caution unlike t.join(1000) /**************************************/ if (((System.currentTimeMillis() - startTime) > patience) && t.isAlive()) { threadMessage("Tired of waiting!"); t.interrupt(); //Shouldn't be long now -- wait indefinitely t.join(); } } threadMessage("Finally!"); } } As i understand it, join waits for the other thread to complete, but in this case, arent both sleep and join doing the same thing? Then why does netbeans throw the caution?

    Read the article

  • SQL Syntax for Complex Scenario (Deals)

    - by Yisman
    hello everyone i have a complex query to be written but cannot figure it out here are my tables Sales --one row for each sale made in the system SaleProducts --one row for each line in the invoice (similar to OrderDetails in NW) Deals --a list of possible deals/offers that a sale may be entitled to DealProducts --a list of quantities of products that must be purchased in order to get a deal now im trying to make a query which will tell me for each sale which deals he may get the relevant fields are: Sales: SaleID (PK) SaleProducts: SaleID (FK), ProductID (FK) Deals: DealID (PK) DealProducts: DealID(FK), ProductID(FK), Mandatories (int) for required qty i believe that i should be able to use some sort of cross join or outer join, but it aint working here is one sample (of about 30 things i tried) SELECT DealProducts.DealID, DealProducts.ProductID, DealProducts.Mandatories, viwSaleProductCount.SaleID, viwSaleProductCount.ProductCount FROM DealProducts LEFT OUTER JOIN viwSaleProductCount ON DealProducts.ProductID = viwSaleProductCount.ProductID GROUP BY DealProducts.DealID, DealProducts.ProductID, DealProducts.Mandatories, viwSaleProductCount.SaleID, viwSaleProductCount.ProductCount the problem is that it doesnt show any product deals that r not fullfiled (probably because of the productid join). i need that also sales that dont have the requiremnets show up, then i can filter out any saleid that exists in this query "where AmountBought thank you for your help

    Read the article

  • PHP While loop seperating unique categories from multiple 'Joined' tables

    - by Hob
    I'm pretty new to Joins so hope this all makes sense. I'm joining 4 tables and want to create a while loop that spits out results nested under different categories. My Tables categories id | category_name pages id | page_name | category *page_content* id | page_id | image_id images id | thumb_path My current SQL join <?php $all_photos = mysql_query(" SELECT * FROM categories JOIN pages ON pages.category = categories.id JOIN image_pages ON image_pages.page_id = pages.id JOIN images ON images.id = image_pages.image_id ");?> The result I want from a while loop I would like to get something like this.... Category 1 page 1 Image 1, image 2, image 3 page 2 Image 2, image 4 Category 2 page 3 image 1 page 4 image 1, image 2, image 3 I hope that makes sense. Each image can fall under multiple pages and each page can fall under multiple categories. at the moment I have 2 solutions, one which lists each category several times according to the the amount of pages inside them: eg. category 1, page 1, image 1 - category 1, page 1, image 2 etc One that uses a while loop inside another while loop inside another while loop, resulting in 3 sql queries. <?php while($all_page = mysql_fetch_array($all_pages)) { ?> <p><?=$all_page['page_name']?></p> <?php $all_images = mysql_query("SELECT * FROM images JOIN image_pages ON image_pages.page_id = " . $all_page['id'] . " AND image_pages.image_id = images.id"); ?> <div class="admin-images-block clearfix"> <?php while($all_image = mysql_fetch_array($all_images)) { ?> <img src="<?=$all_image['thumb_path']?>" alt="<?=$all_image['title']?>"/> <?php } ?> </div> <?php } } ?

    Read the article

  • LINQ to SQL left outer joins

    - by César
    Is this query equivalent to a LEFT OUTER join? var rows = from a in query join s in context.ViewSiteinAdvise on a.Id equals s.SiteInAdviseId where a.Order == s.Order select new {....}; I tried this but it did not result from s in ViewSiteinAdvise join q in query on s.SiteInAdviseId equals q.Id into sa from a in sa.DefaultIfEmpty() where s.Order == a.Order select new {s,a} I need all columns from View

    Read the article

  • join codition in sqlserver

    - by Pallavi
    after applying join condition on two tables i want records which is maximum among records of left table my query SELECT a1.*, t.*, ( a1.trnratefrom - t.trnratefrom )AS minrate, ( a1.trnrateto - t.trnrateto ) AS maxrate FROM (SELECT a.srno, trndate, b.trnsrno, Upper(Rtrim(Ltrim(b.trnstate))) AS trnstate, Upper(Rtrim(Ltrim(b.trnarea))) AS trnarea, Upper(Rtrim(Ltrim(b.trnquality))) AS trnquality, Upper(Rtrim(Ltrim(b.trnlength))) AS trnlength, Upper(Rtrim(Ltrim(b.trnunit))) AS trnunit, b.trnratefrom, b.trnrateto, a.remark, entdate FROM mstprodrates a INNER JOIN trnprodrates b ON a.srno = b.srno)a1 INNER JOIN (SELECT c.srno, trndate, d.trnsrno, Upper(Rtrim(Ltrim(d.trnstate))) AS trnstate, Upper(Rtrim(Ltrim(d.trnarea))) AS trnarea, Upper(Rtrim(Ltrim(d.trnquality))) AS trnquality, Upper(Rtrim(Ltrim(d.trnlength))) AS trnlength, Upper(Rtrim(Ltrim(d.trnunit))) AS trnunit, d.trnratefrom, d.trnrateto, c.remark, entdate FROM mstprodrates c INNER JOIN trnprodrates d ON c.srno = d.srno) AS t ON a1.trnstate = t.trnstate AND a1.trnquality = t.trnquality AND a1.trnunit = t.trnunit AND a1.trnlength = t.trnlength AND a1.trnarea = t.trnarea AND a1.remark = t.remark WHERE t.srno = (SELECT MAX(srno) FROM a1 WHERE srno < a1.srno)

    Read the article

  • mysql left join queries

    - by Mike79
    I have a question about the snippet below. I'm wondering, if the first query doesn't bring any results, would I still get the results for the second query? select * from ( -- first query ) as query1 left join ( -- second query ) as query2 on query1.id=query2.id left join ( -- third query ) as query3 on query1.id=query3.id; Update: what I need is a full join, however, MySQL does not support it, what would be a good way to emulate this?

    Read the article

  • Subquery vs Traditional join with WHERE clause?

    - by BradC
    When joining to a subset of a table, any reason to prefer one of these formats over the other? Subquery version: SELECT ... FROM Customers AS c INNER JOIN (SELECT * FROM Classification WHERE CustomerType = 'Standard') AS cf ON c.TypeCode = cf.Code INNER JOIN SalesReps s ON cf.SalesRepID = s.SalesRepID vs the WHERE clause at the end: SELECT ... FROM Customers AS c INNER JOIN Classification AS cf ON c.TypeCode = cf.Code INNER JOIN SalesReps AS s ON cf.SalesRepID = s.SalesRepID WHERE cf.CustomerType = 'Standard' The WHERE clause at the end feels more "traditional", but the first is arguably more clear, especially as the joins get increasingly complex. Only other reason I can think of to prefer the second is that the "SELECT *" on the first might be returning columns that aren't used later (In this case, I'd probably only need to return cf.Code and Cf.SalesRepID)

    Read the article

  • Problem with nhibernate join

    - by MexicanHacker
    I'm trying to do a join like this using fluent nhibernate: Id(x => x.Id); Map(x => x.SourceSystemRecordId,"sourceSystemRecord_id"); Then Join("cat.tbl_SourceSystemRecords", SourceSystemRecords); But, it seems I don't have a way to specify the column I want to join with from the first table, in this case I need to join on SourceSystemRecordId and not on Id Is there any way I can specify this? I tried References() but that requires me to create an object for this relationship, what I need is to aggregate the columns in sourcesystem records to the ones in the main table.

    Read the article

  • differentiating results of sql right join

    - by Sourabh
    Hi I have a below SQL query SELECT `User`.`username` , Permalink.perma_link_id, Permalink.locale, Permalink.title, DATEDIFF( CURDATE( ) , Permalink.created ) AS dtdiff, `TargetSegment`.segment_text, TargetSegment.source_segment_id ,TargetSegment.perma_link_id ,TargetSegment.created ,TargetSegment.updated, DATEDIFF( CURDATE( ) , TargetSegment.updated ) AS datediff FROM `users` AS `User` RIGHT JOIN perma_links AS `PermaLink` ON ( `PermaLink`.`username` = `User`.`username` ) RIGHT JOIN target_segments AS `TargetSegment` ON ( `TargetSegment`.`username` = `User`.`username` ) RIGHT JOIN source_segments AS `SourceSegment` ON ( `SourceSegment`.`source_detail_id` = `PermaLink`.`source_detail_id` ) LEFT JOIN source_details AS `SourceDetail` ON ( `SourceSegment`.`source_detail_id` = `SourceDetail`.`id` ) WHERE `TargetSegment`.`username` = "xxxx" AND `TargetSegment`.`segment_text` <> "" AND `Permalink`.`perma_link_id` = `TargetSegment`.`perma_link_id` AND `TargetSegment`.`source_segment_id` = `SourceSegment`.`id` AND `Permalink`.`source_detail_id` = `SourceDetail`.`id` ORDER BY `TargetSegment`.`updated` DESC LIMIT 0 , 10 This SQL is fetching correct results for me.I want to identify from which table each row if from , to be specific which result is due to PermaLink table and which is from TargetSegment table. is this achievable ?

    Read the article

  • Which is faster join

    - by Costa
    Hi Which is faster SELECT * FROM X INNER JOIN Y ON x.Record_ID = y.ForignKey_NotIndexed_NotUnique or SELECT * FROM X INNER JOIN Y ON y.ForignKey_NotIndexed_NotUnique = x.Record_ID

    Read the article

  • I’m screwing up this LEFT JOIN

    - by Jason Shultz
    I'm doing a left join on several tables. What I want to happen is that it list all the businesses. Then, it looks through the photos, videos, specials and categories. IF there are photos, then the tables shows yes, if there are videos, it shows yes in the table. It does all that without any problems. Except for one thing. For every photo, it shows the business that many times. For example, if there are 5 photos in the DB for a business, it shows the business five times. Obviously, this is not what I want to happen. Can you help? function frontPageList() { $this->db->select('b.id, b.busname, b.busowner, b.webaddress, p.thumb, v.title, c.catname'); $this->db->from ('business AS b'); $this->db->where('b.featured', '1'); $this->db->join('photos AS p', 'p.busid = b.id', 'left'); $this->db->join('video AS v', 'v.busid = b.id', 'left'); $this->db->join('specials AS s', 's.busid = b.id', 'left'); $this->db->join('category As c', 'b.category = c.id', 'left'); return $this->db->get();

    Read the article

  • Cross-submission robots.txt for multiple domains on single host

    - by sidd.darko
    We are running a site with multiple languages hosted in a single environment on IIS7. For example, oursite.com - english oursite.de - german oursite.es - spanish This is a single-host environment. All of these sites are in the same application space on the same physical machine. I need to do cross-submission of sitemaps via robots.txt. Looking at the sitemap.org guidelines for this suggest this is possible, but the example indicates different physical machines. Will the following entries in oursite.com/robots.txt work? http://www.oursite.com/sitemap-oursite-de.xml http://www.oursite.com/sitemap-oursite-es.xml

    Read the article

  • Cross-forest GPO between 2003 and 2008 Denied Beacuse it's "Inaccessible"

    - by j.rightly
    I have a two-way, non-transitive trust between two forests and domains, "W2003" and "W2008". In W2008 I have a GPO with user settings linked to a machine OU containing machine "Server". The GPO applies to Authenticated Users. Cross-forest loopback processing is enabled in merge mode. When I log onto Server as User (whose account exists in the W2003 domain), the GPO does not apply. I run RSoP and see that the GPO is "Denied" for the reason "Inaccessible." The GPO name is not listed, but the GUID is. I have checked the file-level permissions on the DC to ensure that User has access to read the GPO's folder and all its contents. What is going on?

    Read the article

  • Sharing wireless internet connection between 2 Ubuntu 10.04 systems using cross-over cable

    - by Gary
    I have a Lenovo T60 with Ubuntu 10.04 connected with a cross-over cable to a Dell Vostro 1400, also running Ubuntu 10.04. My internet is coming into the Lenovo through an external wireless antennae, and I want to share the internet with the Dell. On the Lenovo: eth0 connection has IPv4 Settings 'Shared to other computers' I can ping the Dell (10.42.43.10) successfully I can use mtr to trace to www.google.com successfully On the Dell: eth0 connection has IPv4 Settings 'Automatic DHCP' I can ping the Lenovo (10.42.43.1) successfully when I use mtr to trace to www.google.com, I can only reach 10.42.43.1 I must be missing some setting, but cannot see what it is; can anyone help me?

    Read the article

  • Aplication for generating cross table

    - by Ajtak
    I need advice on whether there is an application for generating cross tables. I would imagine it so that I entered at the beginning of team names. Subsequently I wrote results, but always one and the second correct field would enrolled opposite result. I want it to count the total score etc. .. I hope I have expanded well. I would like recommendations for any program. In Excel I dont. Thank you a thousand times for any advice. http://imageshack.us/a/img849/9100/d70m.png

    Read the article

  • Cross Domain access of self hosted WCF services?

    - by Macnique
    I have developed a WPF application which communicates with a set of self hosted WCF services which are under same domain and I use the following setup in the config files. <security mode="Transport"> <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> <message clientCredentialType="Windows" /> </security> I hosted the services on a server in different domain .I can achieve the communication by setting the security mode to "None" which is not ideal. Is there any other setting i can user for cross domain communication or i have to do with some trusted certificates ? I would be glad if some one can guide me because all the searches on google directed me to silverlight applications +Crossdomain.xml+WCF but i have't seen any combination of WPF on crossdomain environment.

    Read the article

< Previous Page | 32 33 34 35 36 37 38 39 40 41 42 43  | Next Page >