Need help to fix my inner join SQL statement and C# code

Wiliam J

I have 2 tables, what I am looking for is:

JobApplic table contains:

ApplicNum, 
JobNum, 
UID "this is the employer", 
Jobtitle, 
AplicUID " this is job seeker" 

CVs table contains:

CVNum, 
UID (here in this table is the job seeker) , 
FN, 
LN, 
etc.... 

The statement it something like that but I am not so professional to write in the correct way:

select 
from [JobApplic] ApplicNum, JobNum, UID, Jobtitle, AplicUID 
where 
     UID 
into table JobApplic = session["UsrNme"], 
inner join table [CVs] UID,FN, LN, ... 
Where UID into table CVs = ApplicUID into table JobApplic"    

The mean point from this code is when employer enter to his account he will be able to see all applicant CV's whose applied for jobs which posted by the employer.

protected void ViewapplCV_Click(object sender, EventArgs e)
{
    if (Session["UsrNme"] != null)
    {
        using (SqlConnection AppCVsSQLCon = new SqlConnection(sc))
        {
            AppCVsSQLCon.Open();

            SqlDataAdapter ApplCVsDAADP = new SqlDataAdapter(@"
               SELECT AD.[ApplicNum], AD.[JobNum], AD.[UID], AD.[Jobtitle],
                      AD.[AplicUID], UI.[UID], UI.[FN], UI.[LN] 
               FROM [JobApplic] AS AD JOIN CVs AS UI ON AD.[UID] = UI.[UID] 
               WHERE AD.UID = @UID AND AD.AplicUID = UI.UID", sc);

            var use = Session["UsrNme"];

            ApplCVsDAADP.SelectCommand.Parameters.AddWithValue("@UID", use);

            DataSet dsApplCVs = new DataSet();

            ApplCVsDAADP.Fill(dsApplCVs);

            showapplicforemployrLV.DataSource = dsApplCVs.Tables[0];
            showapplicforemployrLV.DataBind();
        }
    }
    else
    {
        // Your Session key could not be found, consider displaying an error
    }

    MultiView1.ActiveViewIndex = 12;
}
Steve

If I understand correctly the relationship between these tables then the query should be

SqlDataAdapter ApplCVsDAADP = new SqlDataAdapter(@"
   SELECT AD.[ApplicNum],AD.[JobNum],AD.[UID],AD.[Jobtitle],
          AD.[AplicUID],UI.[UID],UI.[FN],UI.[LN] 
   FROM [JobApplic] as AD JOIN CVs as UI ON AD.[AplicUID] = UI.[UID] 
   WHERE AD.UID = @UID", sc);

You say that the in the first table AplicUID "this is job seeker" and in the second table the UID (here in this table is the job seeker) so you need to make a join between these two fields and there is no need to repeat the relationship again in the WHERE clause

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

need help to fix the link in my javascript code

From Dev

Need help on SQL statement

From Dev

Need help in SQL join

From Dev

Need help in SQL join

From Dev

Need help to fix error and add FCM code in my Android app

From Dev

SQL: Inner join help for assessment

From Dev

SQL Inner Join Help Needed

From Dev

Need help to add more function to my sql statement

From Dev

SQL Count returns wrong value in my INNER JOIN Statement

From Dev

Inner Join in my SQL

From Dev

Need Help on Inner Join two Query

From Dev

SQL Help Inner JOIN LEFT JOIN

From Dev

SQL Help Inner JOIN LEFT JOIN

From Dev

SQL Query Inner Join with statement?

From Dev

SQL select statement inner join

From Dev

SQL select statement inner join

From Dev

Need help to fix my create multi-dimensional array using Object code

From Dev

Need help in finding where to start looking to fix my code. When reading large files it gets stuck

From Dev

Need help debugging C code

From Dev

Need help on writing sql select statement

From Dev

Need help writing an SQL query for a select statement

From Dev

Need help on SQL query (self join)

From Dev

two inner join in one sql statement

From Dev

Inner Join with CASE statement is not working in SQL SERVER

From Dev

SQL Statement Inner Join + Others...So join within a join?

From Dev

Can someone help fix my code?

From Dev

Need help simplifying a method in my code

From Dev

Need help figuring out why my if statement won't pass in Unity c#

From Dev

Missing Data in mysql query, Need conditional statement in inner join