Professional Web Applications Themes

Any experts with help? - MySQL

Having problem with many to many join. Below is the schema with tables and sql statements. All seems to work with the following exception: Can not get all the field names to display. // problem is can not get 'member name' to display // if put 'member.member_lname' in select statement get error msg // Unknown column 'member.member_lname' in 'field list' select member_cccp_lnk.member_dist_no, member_cccp_lnk.cccb_id, cccb.com_name from member_cccp_lnk left join cccb on (cccb.cccb_id = member_cccp_lnk.cccb_id) where member_cccp_lnk.member_dist_no = '0008'; // problem is can not get 'cccb name' to display // if put 'cccb.com_name' in select statement get error msg // Unknown column ...

  1. #1

    Default Any experts with help?

    Having problem with many to many join. Below is the schema with tables
    and sql statements. All seems to work with the following exception: Can
    not get all the field names to display.


    // problem is can not get 'member name' to display
    // if put 'member.member_lname' in select statement get error msg
    // Unknown column 'member.member_lname' in 'field list'

    select member_cccp_lnk.member_dist_no, member_cccp_lnk.cccb_id,
    cccb.com_name
    from member_cccp_lnk
    left join cccb on (cccb.cccb_id = member_cccp_lnk.cccb_id)
    where member_cccp_lnk.member_dist_no = '0008';


    // problem is can not get 'cccb name' to display
    // if put 'cccb.com_name' in select statement get error msg
    // Unknown column 'cccb.com_name' in 'field list'

    select member.member_fname, member.member_lname
    from member_cccp_lnk
    left join member on (member.member_dist_no = member_cccp_lnk.member_dist_no)
    where member_cccp_lnk.cccb_id = '0200';

    create database cccb;

    use cccb;

    DROP TABLE IF EXISTS `cccb`.`cccb`;
    CREATE TABLE `cccb`.`cccb` (
    `cccb_id` int(4) unsigned zerofill NOT NULL,
    `com_name` varchar(50) default NULL,
    PRIMARY KEY (`cccb_id`)
    ) ENGINE=MyISAM DEFAULT CHT=latin1;

    insert into cccb (cccb_id, com_name) values
    (150 ,'Annexation C'),
    (200 ,'Advisory C'),
    (800 ,'Protection C'),
    (1000 ,'Transit C'),
    (1050 ,'Water C');


    DROP TABLE IF EXISTS `cccb`.`member`;
    CREATE TABLE `cccb`.`member` (
    `member_dist_no` int(4) unsigned zerofill NOT NULL,
    `member_fname` varchar(14) NOT NULL,
    `member_lname` varchar(14) NOT NULL,
    PRIMARY KEY (`member_dist_no`)
    ) ENGINE=MyISAM DEFAULT CHT=latin1;

    insert into member (member_dist_no, member_fname, member_lname) values
    (01, "Jerry", "Jones"),
    (02, "Thomas", "Smith"),
    (03, "Jack", "Nicholson"),
    (04, "Anthony", "Ant"),
    (05, "Gary", "Greece"),
    (06, "Chad", "Chad"),
    (07, "Celestine", "Pasta"),
    (08, "Christopher", "Chris"),
    (09, "Guss", "Guy"),
    (10, "Steve", "Sterling"),
    (11, "John", "Jones"),
    (12, "Thomas", "Tomas");



    DROP TABLE IF EXISTS `cccb`.`member_cccp_lnk`;
    CREATE TABLE `cccb`.`member_cccp_lnk` (
    `member_dist_no` int(4) unsigned zerofill NOT NULL,
    `cccb_id` int(5) unsigned zerofill NOT NULL,
    PRIMARY KEY (`member_dist_no`,`cccb_id`)
    ) ENGINE=MyISAM DEFAULT CHT=latin1;

    insert into member_cccp_lnk (member_dist_no, cccb_id) values
    (01, 150),
    (01, 200),
    (01, 550),
    (01, 600),
    (01, 650),
    (01, 850),
    (02, 450),
    (02, 650),
    (02, 800),
    (03, 400),
    (03, 800),
    (04, 350),
    (04, 1050),
    (05, 550),
    (05, 950),
    (06, 200),
    (06, 550),
    (06, 650),
    (06, 800),
    (06, 850),
    (07, 100),
    (07, 200),
    (07, 250),
    (07, 550),
    (07, 650),
    (08, 200),
    (08, 800),
    (08, 1000),
    (09, 500),
    (09, 550),
    (10, 350),
    (11, 200),
    (11, 300),
    (11, 350),
    (12, 200),
    (12, 350),
    (12, 900);



    select member_cccp_lnk.member_dist_no, member_cccp_lnk.cccb_id,
    cccb.com_name
    from member_cccp_lnk
    left join cccb on (cccb.cccb_id = member_cccp_lnk.cccb_id)
    where member_cccp_lnk.member_dist_no = '0008';



    select member.member_fname, member.member_lname
    from member_cccp_lnk
    left join member on (member.member_dist_no = member_cccp_lnk.member_dist_no)
    where member_cccp_lnk.cccb_id = '0200';


    user Guest

  2. #2

    Default Re: Any experts with help?

    Whats the problem,

    I uploaded your db to mysql 5.0.27+GUI-TOOLS 1.2.5 BETA on WindowsXP and all
    *4* queries ran sucessfuly with no errors, and return good data.


    Jared Guest

  3. #3

    Default Re: Any experts with help?

    // problem is can not get 'member name' to display
    // if put 'member.member_lname' in select statement get error msg
    // Unknown column 'member.member_lname' in 'field list'

    I have since created a join that works but I thought the joins I
    submitted should have worked. I was looking for some thoughts as to why
    they did not.



    Jared wrote:
     
    user Guest

Similar Threads

  1. One for the Experts
    By Darryle in forum ASP.NET Data Grid Control
    Replies: 5
    Last Post: October 17th, 07:37 AM
  2. For the experts! Please help!
    By darkone168 in forum Macromedia Flash Sitedesign
    Replies: 3
    Last Post: November 17th, 03:31 AM
  3. Experts?
    By Atrax in forum ASP
    Replies: 0
    Last Post: August 29th, 12:42 AM
  4. Here's one for you ASP.NET experts...
    By Luther Miller in forum ASP.NET General
    Replies: 0
    Last Post: July 3rd, 03:20 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139