DWho
DWho

Reputation: 5

I can't figure out what v_out and v_in mean in a SQL statement

know some basic SQL enough to fix some issues or at least understand how it works, but I got confused with this. I figured out that they're some kind of commands since they're not tables. But I can't find anywhere here or first three pages of Google what exactly does v_in and v_out do.

The most confusing part is:

--some code above
inv_docs.datdoc AS day,
inv_docs.nrdoc AS doc_num,
v_out.article_id AS article_id,
v_out.qty_out AS sent,
--some code bellow

Where did v_out come from? To what is it related? Also bellow where I get to FROM part:

FROM inv_docs_out v_out
     JOIN inv_docs_in v_in ON v_out.lotid = v_in.idlot

Now I have v_out from nowhere, and it's not even connected to inv_docs via a dot (eg. inv_docs.v_in).

Upvotes: 0

Views: 135

Answers (1)

Cleared
Cleared

Reputation: 2590

Those are table aliases, for example if you do

SELECT * FROM table_with_long_name t

You can use t as an alias. For example

SELECT t.date FROM table_with_long_name t WHERE t.name = 'A Name'

So in your case, what the following query does is letting you use v_out instead of inv_docs_out and v_in instead of inv_docs_in.

FROM inv_docs_out v_out
     JOIN inv_docs_in v_in ON v_out.lotid = v_in.idl

Upvotes: 2

Related Questions