SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Left join is possible?can i fetch in single row but all child table data in column

    Hello All,

    I have two tables are as follows:
    Code:
    CREATE TABLE `tbl_lecture` (
      `lecture_id` bigint(20) NOT NULL auto_increment,
      `s_id` bigint(20) NOT NULL,
      `lecture_date` date NOT NULL,
      `lecture_Heading` varchar(500) NOT NULL,
      `lecture_Preparatory` varchar(500) default NULL,
      `lecture_Preparatory_file` varchar(500) default NULL,
      `lecture_Notes` varchar(500) default NULL,
      `lecture_Notes_file` varchar(500) default NULL,
      `lecture_Assignment` varchar(500) default NULL,
      `lecture_Assignment_file` varchar(500) default NULL,
      `isActive` varchar(1) NOT NULL default '0',
      `regDate` datetime NOT NULL,
      PRIMARY KEY  (`lecture_id`)
    )
    
    CREATE TABLE `tbl_lecture_warmup` (
      `LW_id` bigint(20) NOT NULL auto_increment,
      `lecture_id` bigint(20) NOT NULL,
      `WU_Question` varchar(500) NOT NULL,
      `WU_Option1` varchar(500) default NULL,
      `WU_Option2` varchar(500) default NULL,
      `WU_Option3` varchar(500) default NULL,
      `WU_Option4` varchar(500) default NULL,
      `regDate` datetime NOT NULL,
      PRIMARY KEY  (`LW_id`)
    )
    Where tbl_lecture tables one row can contain multiple rows in tbl_lecture_warmup table.
    Sometimes Might not be data in tbl_lecture_warmup.

    So my question is that Left join (Left table :tbl_lecture) is possible?
    If it is possible can i fetch in single row but all child tables(tbl_lecture_warmup) data in column manner.

    Thanks,
    Ujjwal Das
    -::Ujjwal::-
    Visit My Site

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,262
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    LEFT JOIN is definitely possible

    returning all child data in a single row is not possible

    perhaps this article will help you: Minimize Bandwith in One-to-Many Joins
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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