Help with SQL

Posted on 2009-05-22
Medium Priority
Last Modified: 2012-05-07
I have a program that generated SQL for a report. I am not sure what "=" is for in the SELECT section of the query.  For example, the  "ctx_id = v_ctx_basic_info.ctx_id". Not sure what this is doing.   The query does do an inner join on two views by using the ctx_id, but what does this statement do "ctx_id = v_ctx_basic_info.ctx_id"?  Why do I need it?

	ctx_id = v_ctx_basic_info.ctx_id,  
	contract_type_Description = v_ctx_basic_info.contract_type_Description,  
	custom_1 = v_ctx_basic_info.custom_1,  
	Company_Name = v_ctx_basic_info.Company_Name,  
	expriation_date = v_ctx_basic_info.expriation_date,  
	product_description = v_ctx_basic_info.product_description
v_ctx_basic_info INNER JOIN v_ctx_custom on (v_ctx_basic_info.ctx_id=v_ctx_custom.ctx_id)

Open in new window

Question by:gtrapp
  • 2

Expert Comment

ID: 24453172
"ctx_id = v_ctx_basic_info.ctx_id" is simply  renaming the field ctx_id from table v_ctx_basic_info to ctx_id.
SELECT Superman = v_ctx_basic_info.ctx_id FROM v_ctx_basic_info
would result in:

Accepted Solution

Drutch earned 1000 total points
ID: 24453470
Also, I would alias the views/tables in the queries to make them more readable. And, no. You don't need to rename the fields since the original fields are of the same name.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
Article by: Tammy
MySQLTuner is a script written in Perl that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data is retrieved and presented in a brief forma…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question