Home Forums SQL Server 2008 SQL Server Newbies Display two fields of two UNRELATED tables WITHOUT crossjoin RE: Display two fields of two UNRELATED tables WITHOUT crossjoin

  • GilaMonster (2/5/2013)


    In this particular case, since you want the two counts...

    SELECT q1, q2 FROM

    (SELECT Count(a.PK) as q1 FROM Table1 as a) t1,

    (SELECT Count(b.PK) as q2 FROM Table2 as b) t2

    Only in this case though.

    In general the question can't be answered. How can you meaningfully join two completely unrelated tables and have the columns related to each other? If they are completely unrelated, then they probably shouldn't even be in the same query

    Thank you very much.

    I didn't want to join this two tables. I just wanted to understand how can I display two fields of two unrelated tables in one query without sql forcing me to do a crossjoin.

    Thank you very much, with your query now my question solved.

    I just have one more question, why should we write t1 and t2 in front of select statement? If I don't write them it throw error, I can not understand why should we write them.

    ___________________________________
    Computer Enterprise Masoud Keshavarz
    I don't care about hell.
    If I go there I've played enough Diablo to know how to fight my way out.