Deletion based on the result of a 3 table right joins select query (MySQL 3.23)

Ask a Question related to MySQL, Design and Development.

  1. #1

    Default Deletion based on the result of a 3 table right joins select query (MySQL 3.23)

    I am using MySQL 3.23

    I have a relatively complex database with a number of Many to Many
    relationships (using link tables).

    I want to delete all items in the NewsItems table that would be
    returned by this select query:

    SELECT NewsItems.Id
    FROM FeedItemLink RIGHT JOIN (MemberItemSaveFile RIGHT JOIN NewsItems
    ON MemberItemSaveFile.ItemID = NewsItems.Id) ON FeedItemLink.ItemID =
    NewsItems.Id
    where MemberItemSaveFile.ItemID is null and FeedID=54

    Any thoughts?

    (sorry if this is really easy - I'm relatively new to it all).

    Steve

    Steve Guest

  2. Similar Questions and Discussions

    1. Wierd query result on MySQL 5 system
      I have the following table (complete with sample data). When I run the query below on a mysql 4.1.14 system, the only row returned is row 4 as...
    2. Tyring to dictate cell color in table based on query.
      Hello: I'm building a drill-down interface that changes the cell background color based on the database, and I'm not sure about the if statement....
    3. Mysql select query with php
      Hi, I want to create a sql query but don't know if this is possible with mysql. The Query should do the following: Select all db entries from...
    4. PHP and MySQL Table Joins
      I am having a hard time with joins - my following code displays: ..member_name .gender instead of the actual data - I've been reading through...
    5. Result of Mysql Query in a PHP table
      Hi, I've a problem: I want to have the result of my Mysql Query in a Table in my php file. Now I've this: <?
  3. #2

    Default Re: Deletion based on the result of a 3 table right joins selectquery (MySQL 3.23)

    Steve wrote:
    > I am using MySQL 3.23
    >
    > I want to delete all items in the NewsItems table that would be
    > returned by this select query:
    Since you're using MySQL 3.23, you don't have access to multi-table
    delete syntax. That was introduced in MySQL 4.0.

    If you can't upgrde, I'd recommend saving the output of the query, and
    then use it as a list of id values in an "IN" predicate.

    Regards,
    Bill K.
    Bill Karwin Guest

  4. #3

    Default Re: Deletion based on the result of a 3 table right joins select query (MySQL 3.23)

    Bill Karwin wrote:
    > Since you're using MySQL 3.23, you don't have access to multi-table
    > delete syntax. That was introduced in MySQL 4.0.
    >
    > If you can't upgrde, I'd recommend saving the output of the query, and
    > then use it as a list of id values in an "IN" predicate.

    Thanks Bill. I do have full server access so could upgrade - but I'm
    terrified of screwing my server up.

    I recently had to rebuild the server because of some autmatic update
    YUM on the server control panel.

    I have two questions:

    1 Is upgrading relatively painless

    2 Will all my existing queries work?

    Cheers.

    Steve

    Steve Guest

  5. #4

    Default Re: Deletion based on the result of a 3 table right joins select query (MySQL 3.23)

    Peter H. Coffin wrote:
    > Mostly it is, if you don't have a huge number of client applications to
    > be rebound to new libraries. While it is *possible* to make most pre 4.1
    > applications work with post 4.1 servers, the means of doing so is
    > somewhat brittle (Basically, the password hash changed and while you can
    > force old sytle passwords into the authentication you have to be Very
    > Aware of the new/old difference forever until you get the clients
    > updated.)
    >
    > The other usual issue is the routine "use mysqldump to make your backup,
    > don't just restore files". Basically, you're not upgrading, you're
    > removing the old server and putting a new one into place, and loading
    > the data.

    Thanks. I may have a go at the weekend. My log in scripts do use the
    MySQL PASSWORD() function though. I'll have a think about it.

    I DO need to do some complex-ish queries (sub queries etc) and not
    being able to use IN is a bit of an irritation. So I really should
    upgrade.

    Would you advise going the whole hog from 3.23 to 5?

    Thanks for your tips.

    Steve

    Steve Guest

  6. #5

    Default Re: Deletion based on the result of a 3 table right joins selectquery (MySQL 3.23)

    Steve wrote:
    > Thanks. I may have a go at the weekend. My log in scripts do use the
    > MySQL PASSWORD() function though. I'll have a think about it.
    Note in the docs for the PASSWORD() function, they state that this
    function should be used only by the MySQL internals, and they reserve
    the right to change its implementation. You should use a standard
    hashing function instead.

    MD5() and SHA1() used to be recommended, but recently these functions
    have been shown to be breakable. Now SHA-256 is the hashing function
    recommended by NIST, but MySQL doesn't have an implementation built-in
    yet. MySQL AB is prioritizing this. See
    [url]http://bugs.mysql.com/bug.php?id=13174[/url]
    > Would you advise going the whole hog from 3.23 to 5?
    There's one notable place I can think of where queries may break when
    upgrading from 3 to 5. That's the case in which you mix "comma-style"
    joins with "SQL-92 JOIN styl" joins. For example
    SELECT ...
    FROM t1, t2, LEFT JOIN t3 ON ...
    See [url]http://dev.mysql.com/doc/refman/5.0/en/join.html[/url] for this.

    I agree with Peter, back up your databases into a portable format using
    mysqldump. Then restore them after the software upgrade. There have
    been some bugs reported, related to using old databases as-is after an
    upgrade to 5.0.

    Peter also covered the password issue, which is documented in these two
    pages:
    [url]http://dev.mysql.com/doc/refman/5.0/en/old-client.html[/url]
    [url]http://dev.mysql.com/doc/refman/5.0/en/password-hashing.html[/url]

    You should also read other upgrading issues before doing an upgrade:
    [url]http://dev.mysql.com/doc/refman/4.1/en/upgrade.html[/url]
    [url]http://dev.mysql.com/doc/refman/5.0/en/upgrade.html[/url]

    It is recommended by some people to upgrade one release at a time. That
    is, 3.23 to 4.0, 4.0 to 4.1, 4.1 to 5.0. I'm not sure I agree that this
    is necessary; I'd recommend going straight to 5.0, but make sure to
    restore the data from a mysqldump backup.

    Also read about the "mysql_upgrade" program, included in MySQL 5.0.
    [url]http://dev.mysql.com/doc/refman/5.0/en/mysql-upgrade.html[/url]

    Regards,
    Bill K.
    Bill Karwin Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139