• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

SQL problem

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    SQL problem

    trying to do a sql statement here, every time I key in total, it comes on the screen as Totale

    whats going on, am I being xenophobic




    (\__/)
    (>'.'<)
    ("")("") Born to Drink. Forced to Work

    #2
    Try this:

    select *
    from foreign_pool_of_workers

    or

    select *
    from workers
    where workers.nationality not in ("british")

    NOTE: you cannot use a UNION in this query.
    "Experience hath shewn, that even under the best forms of government those entrusted with power have, in time, and by slow operations, perverted it into tyranny. "


    Thomas Jefferson

    Comment


      #3
      Originally posted by EternalOptimist View Post
      trying to do a sql statement here, every time I key in total, it comes on the screen as Totale

      whats going on, am I being xenophobic




      all your sql are belong to nous

      Comment


        #4
        Originally posted by expat View Post
        all your sql are belong to nous
        "take me to your leader"

        Comment


          #5
          Originally posted by Ruprect View Post
          Try this:

          select *
          from foreign_pool_of_workers

          or

          select *
          from workers
          where workers.nationality not in ("british")

          NOTE: you cannot use a UNION in this query.
          I think you'll find

          select worker
          from foreign_pool_of_workers a
          where a.nationality not in ('british','italian')

          is more efficient
          +50 Xeno Geek Points
          Come back Toolpusher, scotspine, Voodooflux. Pogle
          As for the rest of you - DILLIGAF

          Purveyor of fine quality smut since 2005

          CUK Olympic University Challenge Champions 2010/2012

          Comment


            #6
            Originally posted by Ruprect View Post
            Try this:

            select *
            from foreign_pool_of_workers

            or

            select *
            from workers
            where workers.nationality not in ("british")

            NOTE: you cannot use a UNION in this query.
            Behold the warranty -- the bold print giveth and the fine print taketh away.

            Comment


              #7
              "Experience hath shewn, that even under the best forms of government those entrusted with power have, in time, and by slow operations, perverted it into tyranny. "


              Thomas Jefferson

              Comment


                #8
                I prefer an object orientated approach to the Jonny foreigner problem.

                ForeignPoolOfWorkers pool = new ForeignPoolOfWorkers
                ForeignPoolOfWorkers.Where(Columns.Nationality, Comparison.NotEqual, "british").Load
                Originally posted by cailin maith
                Hang on - there is actually a place called Cheddar??

                Comment


                  #9
                  Originally posted by FSM with Cheddar View Post
                  I prefer an object orientated approach to the Jonny foreigner problem.

                  ForeignPoolOfWorkers pool = new ForeignPoolOfWorkers
                  ForeignPoolOfWorkers.Where(Columns.Nationality, Comparison.NotEqual, "british").Load
                  Yuk!

                  Code:
                  public static IQueryable<TSource> WhereIn<TSource, TKey> (
                          this IQueryable<TSource> source1,
                          Expression<Func<TSource, TKey>> keySelector,
                          IEnumerable<TKey> source2) {
                      if (null == source1)
                          throw new ArgumentNullException ("source1");
                      if (null == keySelector)
                          throw new ArgumentNullException ("keySelector");
                      if (null == source2)
                          throw new ArgumentNullException ("source2");
                      Expression where = null;
                      foreach (TKey value in source2) {
                          Expression equal = Expression.Equal (
                                      keySelector.Body,
                                      Expression.Constant (value, typeof (TKey))
                                      );
                          if (null == where)
                              where = equal;
                          else
                              where = Expression.OrElse (where, equal);
                      }
                      return source1.Where<TSource> (
                          Expression.Lambda<Func<TSource, bool>> (
                              where, keySelector.Parameters));
                  }
                  
                  var britishJobsForBritishWorkersHaHa = (from u in db.Workers
                      select new { u.FirstName, u.LastName, u.Nationality }
                      ).WhereIn (u => u.Nationality, new string[] { "Italian", "French", "Polish" });

                  Comment


                    #10
                    public static IQueryable<TSource> WhereIn<TSource, TKey> (
                    this IQueryable<TSource> source1,
                    Expression<Func<TSource, TKey>> keySelector,
                    IEnumerable<TKey> source2) {
                    if (null == source1)
                    throw new ArgumentNullException ("source1");
                    if (null == keySelector)
                    throw new ArgumentNullException ("keySelector");
                    if (null == source2)
                    throw new ArgumentNullException ("source2");
                    Expression where = null;
                    foreach (TKey value in source2) {
                    Expression equal = Expression.Equal (
                    keySelector.Body,
                    Expression.Constant (value, typeof (TKey))
                    );
                    if (null == where)
                    where = equal;
                    else
                    where = Expression.OrElse (where, equal);
                    }
                    return source1.Where<TSource> (
                    Expression.Lambda<Func<TSource, bool>> (
                    where, keySelector.Parameters));
                    }

                    var britishJobsForBritishWorkersHaHa = (from u in db.Workers
                    select new { u.FirstName, u.LastName, u.Nationality }
                    ).WhereIn (u => u.Nationality, new string[] { "Italian", "French", "Polish"
                    });

                    Fancy breaking this down line by line - maybe the less intelligent amongst us may get the joke

                    Comment

                    Working...
                    X