SQL Statement In to SQL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?QmFmZmxlZA==?=

    SQL Statement In to SQL

    Hi All,

    How would I convert the SQL IN statement to LinQ

    Select *
    from TableName
    where FieldName in (Value1, Value2)

    or

    Select *
    from Table1
    where Field1 in (Select Field1 from Table2)

    Thanks
  • Alberto Poblacion

    #2
    Re: SQL Statement In to SQL

    "Baffled" <Baffled@discus sions.microsoft .comwrote in message
    news:CB839267-6392-4D9E-A78A-89D1E15CB526@mi crosoft.com...
    How would I convert the SQL IN statement to LinQ
    >
    Select *
    from TableName
    where FieldName in (Value1, Value2)
    >
    or
    >
    Select *
    from Table1
    where Field1 in (Select Field1 from Table2)

    As to the second one, it can be refactored into a Join:

    Select Table1.* from Table1 Join Table2 on Table1.Field1=T able2.Field1

    This can then be readily converted into a LINQ query with a Join.

    Comment

    Working...