Results 1 to 5 of 5

Thread: Writing a SQL statement on serveral lines [* Resolved *]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Writing a SQL statement on serveral lines [* Resolved *]

    Hello

    I have a SQL statement which is long. How do l write it so that it is on serveral lines.

    This is what l have tried to do.

    Code:
    CnnStr = "SELECT student.studentID, student.FirstName, student.LastName" +
                    "book.bookID, book.Title" +
             "FROM student, book" +
             "WHERE student.studentID = book.studentID";
    This does not work, and anyone tell me how to do this.

    Many thanks in advance,

    Steve
    Last edited by steve_rm; Oct 15th, 2004 at 07:34 AM.
    steve

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    That should work fine, except that you are missing commas and spaces in your statement. Look at the end of each line.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331
    Hello,

    Thanks for your help. I think l was thinking too much like VB. I thought with concatenation you left out the commas.

    Thanks very much,

    Steve
    steve

  4. #4
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Norwich, UK
    Posts
    405
    why are you hardcoding sql into your application?. unless there is a really good reason this is an extremely bad idea. i terms of security, performance, modularity

  5. #5
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Want to do something even cooler? Check it out:

    CnnStr = @"SELECT
    student.studentID,
    student.FirstName,
    student.LastName,
    book.bookID,
    book.Title
    FROM student, book
    WHERE student.studentID = book.studentID";

    That little @ sign is some powerful stuff...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width