php - MySQL SELECT: Returning multiple columns based on a column value in the same table -


I am reading from the same table in the rows containing the file meta information. One of the columns, in ACL, is a flag (0,1 or 2) mapping (unrestricted, restricted or personalized). I want to create a SELECT query that will return the file data on the basis of two PHP variables, $ userId and $additional argument is as follows:

  • Despite the liability of $ infoId or $ if acl = 0 Return file information line Admin value
  • Return file information line if acl = 1 and $ is true admin
  • If ALL = 2 if $ userId = return fileownerid file entry (where fileownerid table Has a column, which has uploaded the file owner ID is stored)

    So basically I am doing a query on the table and returning only to the user who is allowed to view

    I have tried to use all types of case and IF statements but it can not be solved without SQL processing in PSP, it is not possible to do without processing.

    Any guru sees in a way?

    then admin = "text">

    select * and user id for variables of 1 and 2.

Comments