Why isn't this simple left join working?

Why isn't this simple left join working?

jdpassiveincome2jdpassiveincome2 Posts: 3Questions: 2Answers: 0
edited October 2018 in Free community support

Greetings, am i missing something? Why isn't this left join working? I'm getting an error that it can't find the first value and then the table is blank.

 Editor::inst( $db, 'meters_ricoh' )
    ->field(
        Field::inst( 'meters_ricoh.meters_ricoh_lastupdate' ),
        Field::inst( 'meters_ricoh.meters_ricoh_model' ),
        Field::inst( 'meters_ricoh.meters_ricoh_serialnumber' ),
        Field::inst( 'meters_ricoh.meters_ricoh_ipaddress' ),
        Field::inst( 'meters_ricoh.meters_ricoh_totalmeter' ),
        Field::inst( 'meters_ricoh.meters_ricoh_blacknwhite' ),
        Field::inst( 'meters_ricoh.meters_ricoh_colors' ),
        Field::inst( 'meters_ricoh.meters_ricoh_model' ),
        Field::inst( 'masterlist.serialnumber' ),
        Field::inst( 'masterlist.tagnumber' ),
        Field::inst( 'masterlist.customername' ),
        Field::inst( 'masterlist.address1' ),
        Field::inst( 'masterlist.city' ),
        Field::inst( 'masterlist.state' ),
        Field::inst( 'masterlist.zip' )
    )
 
    ->leftJoin( 'masterlist', 'masterlist.serialnumber', '=', 'meters_ricoh.meters_ricoh_serialnumber' )

    ->process($_POST)
    ->json();




      {data: "meters_ricoh_lastupdate"},
      {data: "meters_ricoh_model"},
      {data: "meters_ricoh_serialnumber"},
      {data: "meters_ricoh_ipaddress"},
      {data: "meters_ricoh_totalmeter"},
      {data: "meters_ricoh_blacknwhite"},
      {data: "meters_ricoh_colors"},
      {data: "meters_ricoh_model"},
      {data: "masterlist.serialnumber"},
      {data: "masterlist.tagnumber"},
      {data: "masterlist.customername"},
      {data: "masterlist.address1"},
      {data: "masterlist.city"},
      {data: "masterlist.state"},
      {data: "masterlist.zip"}

Answers

  • jhenryjhenry Posts: 11Questions: 1Answers: 0

    It looks like your fields dont match. Assuming these are the columns from your script

    {data: "meters_ricoh_lastupdate"},
    {data: "meters_ricoh_model"},
    ...
    

    then you are defining your first field as

    meters_ricoh_lastupdate
    

    in your script and the calling it

    meters_ricoh.meters_ricoh_lastupdate
    

    in your server script.

    Are these utility meters by any chance?

This discussion has been closed.