Cross table like cartesian product.

  • Hi,

    I am trying to cross join two tables which doesn't have any relation. Can anyone help me solve this. Here is my details.

    http://www.imageurlhost.com/images/67spn200z5j1wpmzd9hz.png

    Please let me know If I need to provide any details.

  • images are blocked at work, but a cross join is pretty easy

    SELECT T1. *, T2.*

    FROM myTable T1

    CROSS JOIN MyTable T2

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Hi,

    Try this

    select t1.Transport,t2.[Order],t2.Size,t1.Service,

    (select tx.Weight from Table1 tx where tx.type = 'Car') as Car,

    (select tx.Weight from Table1 tx where tx.type = 'Bus') as Bus,

    (select tx.Weight from Table1 tx where tx.type = 'USAirways') as USAirways,

    (select tx.Weight from Table1 tx where tx.type = 'Lufthansa') as Lufthansa,

    t2.Ratio

    from Table1 t1

    Cross join Table2 t2

    Regards,

    Igor

    Igor Micev,My blog: www.igormicev.com

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply