And the moral of the story is, don't try to join
tables using manually-entered string
/varchar
fields. It just won't work. Some people will enter their name as 'Timothy' in some forms, 'Tim' in others and ocassionally 'Timmy'.
Your user
table should have a automatically incrementing numeric primary key
. Your tracker should have a field called user_id
, and you should set up a foreign key
between those two tables.
Then your query would be sensible:
select
t.id,
t.date_implemented,
u.name,
t.comments
from
tracker t
inner join
users u
on t.user_id = u.id
where
t.scheduled_date_start between :d1 and :d2
and
u.username = :uname
-- or if you prefer, u.id = :uid