SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem in select query

    Hello..

    I m doing 1 project in which i have different users like supervisor,technician etc.

    now i want some data to display for supervisor and some for technician.
    I want the data to be display according to the username.

    i have 1 table called ims_incident and other is ims_incident_followup.
    I have 1 column named assigned_to in ims_incident_followup which stores the username. RIght now i have 2 data in assigned_to column i.e 2 and 4(username is the empid of company).


    I m writing this query for getting all the data in gridview.


    select distinct i.incident_id,i.created_by as empid,UPPER (TO_CHAR (created_date, 'dd/mm/yyyy'))
    as createdate,
    (select d.Department_name from ims_department d where d.department_id=i.department_id)
    as department,
    (select a.application_name from ims_add_application a where a.application_id=i.application_id)
    as application,
    (select c.category_name from ims_add_category c where c.category_id=i.category_id)
    as category,
    (select s.subcategory_name from ims_add_subcategory s where s.subcategory_id=i.subcategory_id)
    as subcategory,
    (select st.status_description from ims_add_status st where st.status_code=i.status_code) as status,i.priority,
    (select s.severity_id from ims_add_subcategory s
    where s.subcategory_id= i.subcategory_id)as severity,
    (select f.comments from ims_incident_followup f
    where f.INCIDENT_ID=i.incident_id and f.status_code=i.status_code)as descript,
    (select f.assigned_to from ims_incident_followup f where f.incident_id=i.incident_id and
    f.status_code=i.status_code) as assigned from ims_incident i


    This query is working but both the data is displaying if any1 logs in.
    please reply..

  2. #2
    Non-Member adstiger's Avatar
    Join Date
    Nov 2008
    Location
    Canada
    Posts
    348
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what is the error message of select query?

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by adstiger View Post
    what is the error message of select query?
    he said it was working, so there is no error message
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,510
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    now i want some data to display for supervisor and some for technician.
    I want the data to be display according to the username.
    [...]
    I have 1 column named assigned_to in ims_incident_followup which stores the username.
    In your query you don't use the assigned_to column anywhere. I guess you'll have to some line with it to the join with ims_incident_followup.

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by guido2004 View Post
    In your query you don't use the assigned_to column anywhere.
    yes he does, second last line
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  6. #6
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,510
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by r937 View Post
    yes he does, second last line
    Hmmm, true. But he's only selecting it. I thought from his description of the problem (although it's not very clear ) that he wanted to do some kind of check on this columns value.

  7. #7
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually right now in gridview all the data is displaying but i want to display the records according to assigned_to column.
    so i want to write the condition for this like assigned_to='2' but i dont know where this condition willl come.

  8. #8
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have three records in assigned_to column
    2
    4
    3

    now if suppose 3 is login then only in gridview i want to show the data where assigned_to is equal to 3.

  9. #9
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,510
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Code:
    (select f.comments from ims_incident_followup f
    where f.INCIDENT_ID=i.incident_id 
    and f.status_code=i.status_code
    and f.assigned_to=3) as descript,
    Like this maybe?

  10. #10
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    now i m writing this query and getting proper output..

    select i.incident_id,i.created_by empid,i.CREATED_DATE createdate,id.DEPARTMENT_NAME department,
    iap.APPLICATION_NAME application,iac.CATEGORY_NAME category,isc.SUBCATEGORY_NAME subcategory,
    ias.STATUS_DESCRIPTION status,i.PRIORITY,iast.SEVERITY_TYPE severity,ifp.COMMENTS descript,ifp.ASSIGNED_TO assigned
    from ims_incident_followup ifp, ims_incident i, ims_department id, ims_add_application iap,
    ims_add_category iac,ims_add_subcategory isc,ims_add_status ias,ims_add_severity iast
    where ifp.INCIDENT_ID=i.INCIDENT_ID
    and i.DEPARTMENT_ID=id.DEPARTMENT_ID
    and i.APPLICATION_ID=iap.APPLICATION_ID
    and i.CATEGORY_ID=iac.CATEGORY_ID
    and i.SUBCATEGORY_ID=isc.SUBCATEGORY_ID
    and iac.CATEGORY_ID=isc.CATEGORY_ID
    and i.STATUS_CODE=ias.status_code
    and isc.SEVERITY_ID=iast.SEVERITY_ID
    and ifp.assigned_to=3


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •