Search Results

Search found 6841 results on 274 pages for 'outer join'.

Page 10/274 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Mysql Left Join Null Result

    - by Ozzy
    I have this query SELECT articles.*, users.username AS `user` FROM `articles` LEFT JOIN `users` ON articles.user_id = users.id ORDER BY articles.timestamp Basically it returns the list of articles and the username that the article is associated to. Now if there is no entry in the users table for a particular user id, the users var is NULL. Is there anyway to make it that if its null it returns something like "User Not Found"? or would i have to do this using php?

    Read the article

  • Sql query to get the GrandFather name by doing a self join

    - by mahesh
    Hello all , Can any one please give me the query to get the child name and his grand fathers name For eg - if i have a table Relationships in the i have childid and fatherid columns so how will i get the grandfather, i can easily get the father name by using a join but for grandfather i need to do joins 2 times so can any one help me with this D.Mahesh

    Read the article

  • PHP MySQL join table

    - by Jordan Pagaduan
    $sql = "SELECT logs.full_name, logout.status FROM logs, logout WHERE logs.employee_id = logout.employee_id"; tables -- logs logout I'm having error on this. I search join tables in google. And that's what I got. What is wrong with this code?

    Read the article

  • INNER JOIN Returns Too Many Results

    - by Alon
    I have the following SQL: SELECT * FROM [Database].dbo.[TagsPerItem] INNER JOIN [Database].dbo.[Tag] ON [Tag].Id = [TagsPerItem].TagId WHERE [Tag].Name IN ('home', 'car') and it returns: Id TagId ItemId ItemTable Id Name SiteId 1 1 1 Content 1 home 1 2 1 2 Content 1 home 1 3 1 3 Content 1 home 1 4 2 4 Content 2 car 1 5 2 5 Content 2 car 1 6 2 12 Content 2 car 1 instead of just two records, which these names are "home" and "car". How can I fix it? Thanks.

    Read the article

  • Column-oriented DBMS and JOIN operations

    - by André
    From some of the research I've done on NoSQL, column-oriented databases (like HBase or Cassandra) seem to solve the problem of costly JOIN operations, but I don't get how this approach solves this problem. Can anyone explain it to me and/or link me to interesting documentation regarding this area? Thanks

    Read the article

  • can we use join inside join in mysql?

    - by I Like PHP
    i have 3 tables structure is below tbl_login login_id | login_name 1 | keshav tbl_role role_id | login_id( refer to tbl_login.login_id) 1 | 1 tbl_stuff stuff_id | role_id( refer to tbl_role.role_id) 1 | 1 i need data in follow format stuff_id | login_name 1 | keshav how to use JOIN to retrive the above data in mysql?

    Read the article

  • MySQL SELECT Statment issue

    - by mouthpiec
    Hi, I have the following query which returns 2 tuples SELECT bar_id, bar_name, town_name, bar_telephone, subscription_type_id, type FROM towns, subscriptiontype, regions, bar LEFT JOIN barpictures bp ON bar.bar_id = bp.bar_id_fk WHERE town_id = town_id_fk AND bar.test_field = 0 AND subscription_type_id = subscription_type_id_fk AND region_id = region_id_fk AND (type like 'logo%' OR type IS NULL) The main difference between the tuples is that one has 'type' = logo and the other tuple has 'type' = logo_large. I need that instead of having two tuples, I need that I have 2 type attributes, one holding the "logo" and the other the "logo_large" eg bar_id, bar_name, town_name, bar_telephone, subscription_type_id, type1, type2 is this possible

    Read the article

  • How to output JOINed tables?

    - by ilhan
    $id=(int)$_GET["id"]; $result = mysql_query("SELECT questionstable.*, categorytable.name FROM questionstable INNER JOIN categorytable ON categorytable.id = questionstable.category WHERE id=$id"); $row = mysql_fetch_assoc($result); Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\Program Files\EasyPHP-5.3.4.0\www\scsoru.php on line 33

    Read the article

  • Why is the ( ) mandatory in the SQL statement select * from gifts INNER JOIN sentgifts using (giftID

    - by Jian Lin
    Why is the ( ) mandatory in the SQL statement select * from gifts INNER JOIN sentgifts using (giftID); ? The ( ) usually is for specifying grouping of something. But in this case, are we supposed to be able to use 2 or more field names... in the example above, it can be all clear that it is 1 field, is it just that the parser is not made to bypass the ( ) when it is all clear? (such as in the language Ruby).

    Read the article

  • Mysql join two tables and add column values

    - by Mike
    My knowledge of mysql is not very in depth. If I have two tables that for example look like this: Table1 Date v1 v2 v3 05/01/2010 26 abc 45 05/02/2010 31 def 25 05/03/2010 50 ghi 46 Table2 Date v1 v2 v3 05/01/2010 42 jkl 15 05/02/2010 28 mno 14 05/03/2010 12 pqr 64 How can I join them in a query by their date and have the sum of table1.v1 and table2.v1 and also have the sum of table1.v3 and table2.v3. V2 should be ignored.

    Read the article

  • Mysql SQL join question

    - by David
    I am trying to find all deals information along with how many comments they have received. My query select deals.*, count(comments.comments_id) as counts from deals left join comments on comments.deal_id=deals.deal_id where cancelled='N' But now it only shows the deals that have at least one comment. What is the problem?

    Read the article

  • SQL: GROUP BY after JOIN without overriding rows?

    - by krismeld
    I have a table of basketball leagues, a table af teams and a table of players like this: LEAGUES ID | NAME | ------------------ 1 | NBA | 2 | ABA | TEAMS: ID | NAME | LEAGUE_ID ------------------------------ 20 | BULLS | 1 21 | KNICKS | 2 PLAYERS: ID | TEAM_ID | FIRST_NAME | LAST_NAME | --------------------------------------------- 1 | 21 | John | Starks | 2 | 21 | Patrick | Ewing | Given a League ID, I would like to retrieve all the players' names and their team ID from all the teams in that league, so I do this: SELECT t.id AS team_id, p.id AS player_id, p.first_name, p.last_name FROM teams AS t JOIN players AS p ON p.team_id = t.id WHERE t.league_id = 1 which returns: [0] => stdClass Object ( [team_id] => 21 [player_id] => 1 [first_name] => John [last_name] => Starks ) [1] => stdClass Object ( [team_id] => 21 [player_id] => 2 [first_name] => Patrick [last_name] => Ewing ) + around 500 more objects... Since I will use this result to populate a dropdown menu for each team containing each team's list of players, I would like to group my result by team ID, so the loop to create these dropdowns will only have to cycle through each team ID instead of all 500+ players each time. But when I use the GROUP BY like this: SELECT t.id AS team_id, p.id AS player_id, p.first_name, p.last_name FROM teams AS t JOIN players AS p ON p.team_id = t.id WHERE t.league_id = 1 GROUP BY t.id it only returns one player from each team like this, overriding all the other players on the same team because of the use of the same column names. [0] => stdClass Object ( [team_id] => 21 [player_id] => 2 [first_name] => Patrick [last_name] => Ewing ) [1] => stdClass Object ( [team_id] => 22 [player_id] => 31 [first_name] => Shawn [last_name] => Kemp ) etc... I would like to return something like this: [0] => stdClass Object ( [team_id] => 2 [player_id1] => 1 [first_name1] => John [last_name1] => Starks [player_id2] => 2 [first_name2] => Patrick [last_name2] => Ewing +10 more players from this team... ) +25 more teams... Is it possible somehow?

    Read the article

  • help with t-sql self join

    - by stackoverflowuser
    Based on the following table ID Date State ----------------------------- 1 06/10/2010 Complete 1 06/04/2010 Pending 2 06/06/2010 Active 2 06/05/2010 Pending I want the following ouptut ID Date State --------------------------- 1 06/04/2010 Complete 2 06/05/2010 Active So date is the earliest one and State is the latest one. I am failing to apply self join on the table to get the output. Thanks

    Read the article

  • MYSQL JOIN SELECT Statment - omit duplicated

    - by mouthpiec
    Hi, I am tying to join the following 2 queries but I am having duplicated .... it is possible to remove duplacted fro this: ( SELECT bar_id, bar_name, town_name, bar_telephone, (subscription_type_id *2) AS subscription_type_id FROM bar, sportactivitybar, towns, subscriptiontype WHERE sport_activity_id_fk =14 AND bar_id = bar_id_fk AND town_id = town_id_fk AND subscription_type_id = subscription_type_id_fk ) UNION ( SELECT bar_id, bar_name, town_name, bar_telephone, subscription_type_id FROM bar, towns, subscriptiontype WHERE town_id = town_id_fk AND subscription_type_id = subscription_type_id_fk ) ORDER BY subscription_type_id DESC , RAND( ) Please note that I need to omit those duplicates that will have a lower subscription_type_id

    Read the article

  • filter duplicates in SQL join

    - by Will
    When using a SQL join, is it possible to keep only rows that have a single row for the left table? For example: select * from A, B where A.id = B.a_id; a1 b1 a2 b1 a2 b2 In this case, I want to remove all except the first row, where a single row from A matched exactly 1 row from B. I'm using MySQL.

    Read the article

  • Doctrine: Update Join?

    - by Tom
    Hi, Anyone know how to do an update with a join (i.e. update on two tables in one query) in Doctrine 1.2? I spotted something obscure on a forum that hinted that this is not supported in 1.x but it was about as vague as it comes. Thank you.

    Read the article

  • how to join 3 relational tables

    - by orioncabbar
    Hello there, how to join 3 relational tables with the structure: t1 | id t2 | id | rating t3 | source_id | relation t3 stores the data of a field which t1 and t2 uses both. so source_id field can be t1's id or t2's id. input : t1 id output : t2 rating an example: **t1** id | --------- 42 | **t2** id | rating ------------- 37 | 9.2 **t3** id | source_id -------------- 42 | 1 37 | 1 26 | 2 23 | 1 what i want is to get 9.2 output with 42 input. can you do that in one sql query?

    Read the article

  • Join a list of lists together into 1 list in Python

    - by dotty
    Hay All. I have a list which consists of many lists, here is an example [ [Obj, Obj, Obj, Obj], [Obj], [Obj], [ [Obj,Obj], [Obj,Obj,Obj] ] ] Is there a way to join all these items together as 1 list, so the output will be something like [Obj,Obj,Obj,Obj,Obj,Obj,Obj,Obj,Obj,Obj,Obj] Thanks

    Read the article

  • Conditional Join In LINQ?

    - by Soo
    I am trying to write a query that grabs information from one database and joins it to information in a different database. TableA idA valueA idB TableB idB valueB The tricky part is that in TableA, idB isn't always defined, so when I do a normal join, I only get results where TableA has a idB value. What I want is to be able to grab all of the information from TableA even if it doesn't have a corresponding idB value.

    Read the article

  • How can I join conditionally in LINQ queries?

    - by Steve Crane
    If I have two tables; Drivers keyed by DriverId and Trips with foreign keys DriverId and CoDriverId, and I want to find all trips where a driver was either the driver or co-driver I could code this in Transact-SQL as select d.DriverId, t.TripId from Trips t inner join Drivers d on t.DriverId = d.DriverId or t.CoDriverId = d.DriverId How could this be coded as a LINQ query?

    Read the article

  • inner join in sql

    - by vini
    SELECT TotalItems.Total_Items ,TotalItems.No_Items_Present ,ItemsTable.No_Of_Items_Ret FROM TotalItems INNER JOIN ItemsTable ON ItemsTable.Item_Name= '" + DropItemName.SelectedValue + "'" this is my SQL query what I want is to retrieve two column values corresponding to the item I enter in my dropdown list from one table and the no_of_items_ret from another table satisfying the condition of the dropdownlist I'm getting all the values corresponding to any item I enter what should i do?

    Read the article

  • django join querysets from multiple tables

    - by dana
    if i have queries on multiple tables like: d = Relations.objects.filter(follow = request.user).filter(date_follow__lt = last_checked) r = Reply.objects.filter(reply_to = request.user).filter(date_reply__lt = last_checked) article = New.objects.filter(created_by = request.user) vote = Vote.objects.filter(voted = article).filter(date__lt = last_checked) and i want to display the results from all of them ordered by date (i mean not listing all the replies, then all the votes, etc ). Somehow, i want to 'join all these results', in a single queryset. Is there possible?

    Read the article

  • Mysql Left join with condition on column

    - by skicster
    Hi, can you help me with sql query? I have this problem: I have two tables "Join" table: Reservation_has_meal +----------------+ | id_reservation | | id_meal | | pieces | +----------------+ and table with data: Meal +-------------+ | id_meal | | name | +-------------+ Sample data for Meal: 1 | carrot 2 | potatoe 3 | cucumber Reservation_has_meal 1 | 2 | 5230 1 | 3 | 1203 How can I get this result for reservation with id_reservation=1: id_meal | id_Reservation | name | pcs | -------------------------------------------- 1 | 1 | carrot | null| 2 | 1 | potatoe | 5230| 3 | 1 | cucumber | 1203| -------------------------------------------- And result for id_reservation = 2: id_meal | id_Reservation | name | pcs | -------------------------------------------- 1 | 2 | carrot | null| 2 | 2 | potatoe | null| 3 | 2 | cucumber | null| -------------------------------------------- Thanks for advice.

    Read the article

  • MySQL 5 left join unknown column

    - by NP
    I had the below query working in mysql 4.1, but does not in 5.0: SELECT * FROM email e, event_email ee LEFT JOIN member m on m.email=e.email WHERE ee.email_id = e.email_id The error: 1054 (Unknown column 'e.email' in 'on clause')

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >