Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Dots to indicate an alias or something?

Featured Replies

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.

  • Author

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.   

It helps to see ExecuteSQL as a function that can be nested as can many other functions. Hence the Let function etc.

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?

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.

"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!

  • 8 years later...
  • Newbies

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/

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.