David Nelson Posted July 31, 2013 Share Posted July 31, 2013 Okay I can't find an example now. But I see where SQL looks like this: Select * FROM t2.table 2 ... I cannot find where the t2. comes from. Is this an alias, or is this saying "I am naming this table t2 so when I talk about it and say t2 you should know what I mean. oh can someone just point me to something which explains what this thing is even called? I can't look it up because a. and b. and t2. were not the names of the tables in the examples I looked at. t2. isn't a real thing, is it? I think I could have used this idea recently on something I couldn't figure out if only I knew what it meant. Know what I mean? I don't think it is called alias because that seems to be AS. And yes I searched but I only knew to look for sql alias or sql table name but nothing came up. I'm a dork. Link to comment Share on other sites More sharing options...
MetaSys Software Posted July 31, 2013 Share Posted July 31, 2013 here is reference link http://www.w3schools.com/sql/sql_alias.asp Link to comment Share on other sites More sharing options...
David Nelson Posted August 3, 2013 Author Share Posted August 3, 2013 Thank you for this. I have much to learn. I collect various calculations people on various forums produce and then try to understand them. Maybe I'm approaching it improperly and I should instead study SQL first to where I understand how it works and then look at FM examples which use them. It is also confusing because when I look at SQL examples they are not same as when placed inside ExecuteSQL. And some people list custom functions inside them and some in Let() which I just read about. And it is important how this all works together and it isn't yet clear to me. What I have are ExecuteSQL examples I've collected which use a. and b. but nowhere in the calc does it show how it named them and I don't know how FM could have any idea of which table they were talking about. And now I can't even find any of those examples. Regardless, this is what I need to keep moving forward. Link to comment Share on other sites More sharing options...
Rick Whitelaw Posted August 4, 2013 Share Posted August 4, 2013 It helps to see ExecuteSQL as a function that can be nested as can many other functions. Hence the Let function etc. Link to comment Share on other sites More sharing options...
Charity Posted August 9, 2013 Share Posted August 9, 2013 I agree it is confusing, David. I was just looking at such a strange thing myself today: SELECT e.BusinessEntityID , p.Title , pp.PhoneNumber , pnt.Name AS PhoneNumberType , ea.EmailAddress , a.AddressLine1 , sp.Name AS StateProvinceName , cr.Name AS CountryRegionName Sorry it pasted wrong. But the first three lines do not have an AS but yet they reference as e.BusinessEntityID. How does FM know which table the e is talking about? This is from recent thread here http://solutioncenter.apexsql.com/sql-formatting-standards-joins-lists-structure-operations/ If I am FM and I see SELECT e.ID, how in heavens does it know which table I am talking about if all my table primary keys are ID? Link to comment Share on other sites More sharing options...
Fitch Posted August 9, 2013 Share Posted August 9, 2013 In the thread you linked, those prefixes are defined below the SELECT statement, in the FROM statement. E.g., "INNER JOIN Person.Address a" defines "a" as the Person.Address table. It's optional to write it "AS a" -- maybe that's what confused you. It seems sort of backwards at first -- how can you use the alias in the SELECT statement before it's even been defined? But that's how you do it in SQL-land. 1 Link to comment Share on other sites More sharing options...
Charity Posted August 9, 2013 Share Posted August 9, 2013 "how can you use the alias in the SELECT statement before it's even been defined? But that's how you do it in SQL-land." Oh you nailed my confusion, Tom!!! How you can use an 'alias' before you define it. As for the other thread, it didn't work. I will put together a sample after lunch and maybe you or someone can help me understand what I am doing wrong. And thank you so much! Link to comment Share on other sites More sharing options...
Newbies tonyedented Posted April 20, 2022 Newbies Share Posted April 20, 2022 Alias in SQL is basically a temporary name that is given to a table or a column while writing a query. This is usually done when the column or the table names are long, so in order to render more readability, alias is given. The alias in SQL is a temporary change and only exists till the duration of that query. For column alias SELECT column_name AS alias_name FROM table_name; For table alias SELECT column_1,column_2... FROM table_name AS alias_name; Example Query SELECT M.Office_id,O.Target_Area,M.Manager_name FROM India_Offices AS O,Managers AS M WHERE O.Office_id_India=M.Office_id; To learn more refer to this article: https://www.scaler.com/topics/alias-in-sql/ Link to comment Share on other sites More sharing options...
Recommended Posts
This topic is 730 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 accountSign in
Already have an account? Sign in here.
Sign In Now