Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

simcha's avatar

Same query ... in code and DB agent

Congratulations

Encountered a strange problem

The same query, in TablePlus' GUI returns rows While in the code returns an empty array.

What could be the reason?

SELECT *
FROM `records`
  INNER JOIN `meta_records` AS `data0` ON `data0`.`record_id` = `records`.`id`
  INNER JOIN `meta_records` AS `data1` ON `data1`.`VALUE` = `data0`.`VALUE`
WHERE `data1`.`record_id` = 116
  and (
    `data0`.`field_id` = 12
    and `data0`.`field_type` = 'App\Models\Field'
  )
  and (
    `data1`.`field_id` = 12
    and `data1`.`field_type` = 'App\Models\Field'
  )
  and (
    (
      EXISTS (
        SELECT *
        FROM `meta_records` AS `meta_exists`
        WHERE `meta_exists`.`field_id` = 14
          and `meta_exists`.`VALUE` > 750
          and `meta_exists`.`record_id` = `data1`.`record_id`
      )
    )
  )
0 likes
2 replies
simcha's avatar
simcha
OP
Best Answer
Level 7

Sorry, the mistake was mine, it was in the middle of a transaction with a database that with the dd it did not end and the filled out result did not match what was in the DB after the transaction.

Please or to participate in this conversation.