title: MySQL error message,error code 1064,LIMIT 20 OFFSET 0
body: <p>I want to join 2 tables. The one contains users and the other appointments-the appointments table contains 3 columns(ApID,which is the primary key),bookFrom,bookedFor-these last 2 columns reference the users table and I think it is easy self_explanatory what they mean.
  Here are the tables in detail:</p>
  
  <pre><code>    CREATE TABLE `users` (
   `user_ID` int(11) NOT NULL AUTO_INCREMENT,
   `name` varchar(45) NOT NULL,
   `lastname` varchar(45) NOT NULL,
   `email` varchar(255) DEFAULT NULL,
   `password` varchar(100) DEFAULT NULL,
   `hash` varchar(32) DEFAULT NULL,
   `usertype` enum('1','2','3','4') DEFAULT NULL,
   PRIMARY KEY (`user_ID`),
   KEY `fk_users_usertype1_idx` (`usertype`),
   CONSTRAINT `fk_users_usertype1` FOREIGN KEY (`usertype`) REFERENCES `usertype` (`type_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
  ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8
  
      CREATE TABLE `appointments` (
   `apID` int(11) NOT NULL AUTO_INCREMENT,
   `Bookfrom` int(11) ,
   `bookedfor` int(11) ,
   PRIMARY KEY (`apID`),
   KEY `fk_appointments_user1_idx` (`Bookfrom`),
   KEY `bokkedfor` (`bookedfor`),
   CONSTRAINT `appointments_ibfk_3` FOREIGN KEY (`bookedfor`) REFERENCES `users` (`user_ID`) ON DELETE CASCADE ON UPDATE CASCADE,
   CONSTRAINT `appointments_ibfk_2` FOREIGN KEY (`Bookfrom`) REFERENCES `users` (`user_ID`) ON DELETE CASCADE ON UPDATE CASCADE
  ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8
  </code></pre>
  
  <p>What I am trying to find  is if a specific user(that user has an email of papageorgiou40@testmail.com) is listed in the appointments table(meaning has booked an appointment) and I am trying to do this with this statement:</p>
  
  <pre><code>select  appointments.Bookfrom,appointments.Bookedfor 
  from appointments,users 
  where users.email='papageorgiou40@test.com' 
  and appointments.Bookfrom=users.user_ID,
  appointments.Bookedfor=users.user_ID;
  </code></pre>
  
  <p>But I get the following message:</p>
  
  <blockquote>
    <p>Error code 1064, SQL state 42000: You have an error in your SQL
    syntax; check the manual that corresponds to your MySQL server version
    for the right syntax to use near '
    appointments.Bookedfor=users.user_ID LIMIT 20 OFFSET 0' at line 4</p>
  </blockquote>
  
  <p>You might wonder why 2 columns bookedfrom and bookedfor. The reason is that in the users table there are 2 types of users, business and regular users, so the logic is a regular user who books an appointment for a business one.I am not sure this the proper db design for the occasion but that is a different discussion</p>