#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    1
    Rep Power
    0

    One query in 3 conditions


    0 down vote favorite


    I have one table in database that contains 3 foreign keys to another tables(this three tables name are: manager,worker and employee). in each row only one foreign key is filled.I need to write one query that with attention which column of fk is filled in where clause specified condition is performed. I write simple query in jpa but doesn't work properly

    select b from allEmployees b where b.manager.name= :name OR b.worker.name = :name OR b.employee.name= :name
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    840
    Rep Power
    387

    Cool


    Originally Posted by sepand
    . . . . . I write simple query in jpa but doesn't work properly
    Code:
    SELECT b
      FROM allemployees b
     WHERE b.manager.name = :name
        OR b.worker.name = :name
        OR b.employee.name = :name
    The query you wrote is not valid for JPA or any of the known sql languages.

IMN logo majestic logo threadwatch logo seochat tools logo