-1

In a large query, I have

INNER JOIN file
ON ( file.file_id = temp_student_table.converted_file 
     OR file.file_id = temp_student_table.uploaded_file)

If file.file_id = temp_student_table.converted_file is a match, does MySQL check for the second statement? what happens if both of them return a match? Does it only consider the first statement?

fedorqui
  • 275,237
  • 103
  • 548
  • 598
Nu Gnoj Mik
  • 994
  • 3
  • 10
  • 25

3 Answers3

0

Since you are using an OR operator here it checks for the first condition.If the first statement is matched then it proceeds.The second one need not be matched in the condtion

Avinash Babu
  • 6,171
  • 3
  • 21
  • 26
0

In an OR condition, it will just evaluate the first condition and exit if it is already true.

OR operator has this behaviour:

A | B | A OR B
0   0     0
0   1     1            0 = False
1   0     1            1 = True
1   1     1

This means the A OR B is true unless A and B are false. For this, A OR B will evaluate the minimum necessary: if A is already true, there is no point in continuing to evaluate the condition.

fedorqui
  • 275,237
  • 103
  • 548
  • 598
0

In Mysql, OR will return true:

  • if the first operand is true, in that case the second operand won't be tested
  • if the first operand is false and the second one is true
fluminis
  • 3,575
  • 4
  • 34
  • 47