Jump to content

Syntax for inner join


chanchal
 Share

This topic is 6059 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

I need to inner join 2 tables using JDBC.I am using SQL Server database and my tablenames are BS_1137_2_8 and ReservedInventory and I am using following code:

String str="select top 1 t1.ticketinfo , t1.seat from BS_1137_1_28 t1";

str+="inner join ReservedInventory RI1 on t1.ticketinfo=RI1.id and " + "RI1.status=-1";

ResultSet rs=stmt.executeQuery(str);

When I run the program then it gives error saying that colum prefix t1 does not match with a table name or alias name used in the query.Though I have given alias t1 to table BS_1137_2_8 and when I execute only this part "select top 1 t1.ticketinfo , t1.seat from BS_1137_1_28" then it successfully executes.I am not sure if concatenation is done correctly or not.Can anybody help me??

Link to comment
Share on other sites

  • 1 year later...

This topic is 6059 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.