<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Complex Query - Distance between cities in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830548#M4861391</link>
    <description>&lt;P&gt;No preference, really, Volker.&lt;/P&gt;</description>
    <pubDate>Fri, 15 Jun 2012 06:52:08 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2012-06-15T06:52:08Z</dc:date>
    <item>
      <title>Complex Query - Distance between cities</title>
      <link>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaq-p/13830539</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have 2 tables, &lt;BR /&gt;
the first has columns SourceCodeCity, TargetCodeCity and Distance (there is no NameCity on it).&lt;BR /&gt;
The second has columns CodeCity and NameCity.&lt;BR /&gt;
I need a query to show a table almost like this..&lt;BR /&gt;
NameCity(SourceCodeCity) | NameCity(TargetCodeCity) | Distance&lt;BR /&gt;
Can you help-me ?&lt;BR /&gt;
I tried with select and some joins but does not work&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2012 10:11:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaq-p/13830539</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-06-14T10:11:24Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Query - Distance between cities</title>
      <link>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830540#M4861383</link>
      <description>&lt;P&gt;Let's suppose the first table is called DISTANCES, the second table is called CITYNAMES.&lt;/P&gt;
&lt;P&gt;You want something like&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="n"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="n"&gt;SOURCE&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;NameCity&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;TARGET&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;NameCity&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;DISTANCES&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;Distance&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;FROM&lt;/SPAN&gt; &lt;SPAN class="n"&gt;DISTANCES&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;CITYNAMES&lt;/SPAN&gt; &lt;SPAN class="n"&gt;AS&lt;/SPAN&gt; &lt;SPAN class="n"&gt;SOURCE&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;CITYNAMES&lt;/SPAN&gt; &lt;SPAN class="n"&gt;AS&lt;/SPAN&gt; &lt;SPAN class="n"&gt;TARGET&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;WHERE&lt;/SPAN&gt; &lt;SPAN class="n"&gt;DISTANCES&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;SourceCodeCity&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;SOURCE&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;CodeCity&lt;/SPAN&gt; &lt;SPAN class="n"&gt;AND&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;DISTANCES&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;TargetCodeCity&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;TARGET&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;CodeCity&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 14 Jun 2012 12:52:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830540#M4861383</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-06-14T12:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Query - Distance between cities</title>
      <link>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830541#M4861384</link>
      <description>&lt;P&gt;'Tis an old and valuable technique, using different correlation names to allow a table to be joined to itself in a FROM clause.&lt;/P&gt;
&lt;P&gt;So old, in fact, that it got dropped from the docs somewhere between Version 5.5 and 12... well, not dropped, but moved to an obscure topic that implies you must use the WITH clause (you don't): &lt;A href="http://dcx.sybase.com/index.html#1201/en/dbusage/ug-commontblexpr-s-3099894.html"&gt;http://dcx.sybase.com/index.html#1201/en/dbusage/ug-commontblexpr-s-3099894.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Perhaps this sentence from the Version 5.5 docs should be added to the V12 topic on the FROM clause &lt;A href="http://dcx.sybase.com/index.html#1201/en/dbreference/from-statement.html"&gt;http://dcx.sybase.com/index.html#1201/en/dbreference/from-statement.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;SQL Anywhere User's Guide &lt;/P&gt;
&lt;P&gt;PART 6. SQL Anywhere Reference&lt;/P&gt;
&lt;P&gt;CHAPTER 43. Watcom-SQL Statements&lt;/P&gt;
&lt;P&gt;FROM clause&lt;/P&gt;
&lt;P&gt;The correlation name is also necessary to distinguish between table instances when referencing the same table more than once in the same query.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2012 14:27:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830541#M4861384</guid>
      <dc:creator>Breck_Carter</dc:creator>
      <dc:date>2012-06-14T14:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Query - Distance between cities</title>
      <link>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830542#M4861385</link>
      <description>&lt;P&gt;It's a good question, but... apparently there is an unintended consequence to marking it "community wiki": you don't get points when someone votes "up".&lt;/P&gt;
&lt;P&gt;Maybe you don't care about the points, but... you do need points to do some things: &lt;A href="http://sqlanywhere-forum.sap.com/faq/"&gt;http://sqlanywhere-forum.sap.com/faq/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2012 14:44:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830542#M4861385</guid>
      <dc:creator>Breck_Carter</dc:creator>
      <dc:date>2012-06-14T14:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Query - Distance between cities</title>
      <link>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830543#M4861386</link>
      <description>&lt;P&gt;Thanks a lot Glenn,&lt;/P&gt;
&lt;P&gt;It works exactly as I needed.&lt;BR /&gt;
About your observation, and seeing your photo.&lt;BR /&gt;
We use to say here, "God gives hair to some people and brains to others". (lol)&lt;BR /&gt;
Thanks for sharing your vast knowledge.&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Paulo Braga&lt;BR /&gt;
Curitiba - Brazil&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2012 14:56:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830543#M4861386</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-06-14T14:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Query - Distance between cities</title>
      <link>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830544#M4861387</link>
      <description>&lt;P&gt;This is my first issue, I wasn't sure what this Comunity Wiki means..&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2012 14:59:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830544#M4861387</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-06-14T14:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Query - Distance between cities</title>
      <link>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830545#M4861388</link>
      <description>&lt;P&gt;Thanks for that..... I think.....&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2012 15:05:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830545#M4861388</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-06-14T15:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Query - Distance between cities</title>
      <link>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830546#M4861389</link>
      <description>&lt;P&gt;Thanks for the suggestion, Breck. I have communicated that suggestion to the doc team.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2012 15:51:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830546#M4861389</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-06-14T15:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Query - Distance between cities</title>
      <link>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830547#M4861390</link>
      <description>&lt;P&gt;&lt;A href="https://sqlanywhere-forum.sap.com/users/18/glenn-paulley/"&gt;@Glenn&lt;/A&gt;: Wouldn't you prefer a JOIN condition instead of a WHERE clause here, such as&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="k"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="k"&gt;SOURCE&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;NameCity&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;TARGET&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;NameCity&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;DISTANCES&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;Distance&lt;/SPAN&gt;
&lt;SPAN class="k"&gt;FROM&lt;/SPAN&gt; &lt;SPAN class="n"&gt;DISTANCES&lt;/SPAN&gt;
  &lt;SPAN class="k"&gt;INNER&lt;/SPAN&gt; &lt;SPAN class="k"&gt;JOIN&lt;/SPAN&gt; &lt;SPAN class="n"&gt;CITYNAMES&lt;/SPAN&gt; &lt;SPAN class="k"&gt;AS&lt;/SPAN&gt; &lt;SPAN class="k"&gt;SOURCE&lt;/SPAN&gt; &lt;SPAN class="k"&gt;ON&lt;/SPAN&gt; &lt;SPAN class="n"&gt;DISTANCES&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;SourceCodeCity&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="k"&gt;SOURCE&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;CodeCity&lt;/SPAN&gt;
  &lt;SPAN class="k"&gt;INNER&lt;/SPAN&gt; &lt;SPAN class="k"&gt;JOIN&lt;/SPAN&gt; &lt;SPAN class="n"&gt;CITYNAMES&lt;/SPAN&gt; &lt;SPAN class="k"&gt;AS&lt;/SPAN&gt; &lt;SPAN class="n"&gt;TARGET&lt;/SPAN&gt; &lt;SPAN class="k"&gt;ON&lt;/SPAN&gt; &lt;SPAN class="n"&gt;DISTANCES&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;TargetCodeCity&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;TARGET&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;CodeCity&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;(Yes, the outcame is surely identical here.)&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jun 2012 03:15:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830547#M4861390</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2012-06-15T03:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Query - Distance between cities</title>
      <link>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830548#M4861391</link>
      <description>&lt;P&gt;No preference, really, Volker.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jun 2012 06:52:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830548#M4861391</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-06-15T06:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Query - Distance between cities</title>
      <link>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830549#M4861392</link>
      <description>&lt;P&gt;FYI I have updated the FAQ to include a question on Community Wiki.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jun 2012 07:48:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/complex-query-distance-between-cities/qaa-p/13830549#M4861392</guid>
      <dc:creator>graeme_perrow</dc:creator>
      <dc:date>2012-06-15T07:48:17Z</dc:date>
    </item>
  </channel>
</rss>

