How to add empty rows to the JQGrid?

SQL query to add a column based on matches in two rows?

  • I have fields as Name, Org ID, email, designation. Now, I want to add a new column with email where it matches the org ID and particular designation. For example, the user_table is like Name Org ID, Email, Designation Alex xx1 [email protected] Manager Tom xx2 [email protected] Supervisor Abc xx1 [email protected] Engineer Ron xx2 [email protected] Engineer The output that I want should look like this ------------------------ Name Org ID, Email, Designation New Alex xx1 [email protected] Manager [email protected] Tom xx2 [email protected] Supervisor [email protected] Abc xx1 [email protected] Engineer [email protected] Ron xx2 [email protected] Engineer [email protected] The idea here is to add a new column with email ID where Org ID matches and Designation = Engineer. I tried to make sql query like this: select Name, Org ID, Email, Designation, (select t1.Email from user_table t1 where t1.Org ID = Org ID and Designation = "Engineer") as New from user_table But, this seems to be not working. Please suggest me how I can do this? Also, how do I add the same thing in excel.

  • Answer:

    select user_table.Name, user_table.Org ID, user_table.Email, Designation, t1.Email as New from user_table,t1 where t1.Org ID = user_table.Org ID and user_table.Designation = "Engineer" group by user_table.name

vikas p at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Try this: select Name, Org ID, Email, Designation, (select t1.Email from user_table t1 where t1.[Org ID] = t2.[Org ID] and t1.Designation = 'Engineer') as New from user_table t2

I'm not sed to excel but in php I have worked SQL org I'd however doesn't look like a variable to me?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.