MySQL query outputs odd rows only

mysql, php, sql

Solution

You should probably be using a Logical AND (`AND`) instead of a Bitwise AND (`&`) in the where clause:

WHERE user_words.sys_words_ref = sys_words.sys_words_ref 
 AND user_words.user_info_ref = '1'

Problem

I have the following PHP method that returns a JSON string from a MySQL query: ``` $sys_words_ref_join_query = mysql_query(" SELECT user_words.*, sys_words.* FROM user_words, sys_words WHERE user_words.sys_words_ref = sys_words.sys_words_ref & user_words.user_info_ref = '1' LIMIT 0, 7 "); $json_array = array(); while($words_obj = mysql_fetch_object($sys_words_ref_join_query)) { $json_array[] = $words_obj; } $result = json_encode($json_array); echo $result; ``` The problem I'm having is that the `$result` is echoing only odd DB rows, eg. 1,3,5..., etc. Any idea why? Thanks.

Original source