Delete Mysql Query NOT USING SUB-SELECT.
I need a DELETE that represent the sql below:
SELECT L.pk FROM t1 L LEFT JOIN t2 F ON F.fk = L.pk WHERE F.fk IS NULL
NOT USING SUB-SELECT.
View Complete Forum Thread with Replies
Related Forum Messages:
Mysql Delete - $query = Mysql_query("DELETE
how would i do the following ? $query = mysql_query("DELETE notes, datestamp, abs_value, ID FROM absence_mgt WHERE datestamp='$date' AND ID='$vtc_login' ") or die(mysql_error()); im just getting "Unknown table 'notes' in MULTI DELETE" ?
View Replies !
Select & Delete Mysql Queries
i've try to insert and delete record at the same page, but it only can insert and can't delete the record. when i click submit button from the previous form, the record is insert into table B and delete from the table A. is the code correct? Code:
View Replies !
Mysql Query : Delete From *
When I use phpmyadmin, and run this sql query, it will tell me that it affected X amount of rows (lets say 10). However, when i run my script, it doesnt' tell me that. Code:
View Replies !
Delete Query - Error In Your SQL Syntax; Check The Manual That Corresponds To Your MySQL Server
I have tried to make a delete query but it won't work it gives me a syntax error but I'm unsure where i have gone wrong.... this is what i have got at the moment: Quote$Deletesoldhouses = "DELETE * FROM soldhouses WHERE SoldHouseID = '$HouseID'"; mysql_query($Deletesoldhouses) or die(mysql_error()); Can any one see what i did wrong? Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM soldhouses WHERE SoldHouseID = '1'' at line 1
View Replies !
Mysql Query - Select Any
I have the following sql statemant to search a mysql database that gets if values from a form with combo box's in. SELECT * FROM hottubs, manufacturers WHERE manufacturers.manid = hottubs.manid AND hottubs.type = '%s' AND hottubs.dimlength <= '%s' AND hottubs.dimwidth <= '%s' AND hottubs.dimhight <= '%s' AND hottubs.seatsto <= '%s' AND hottubs.shape = '%s' ORDER BY $thesearchtype_search. Everything works fine except I want to add a select "any" from the shape combo box. I really need a way of cutting out the last " AND hottubs.shape = '%s' " if the $_GET['shape'] = 'any' Will this work using a variable as shown below?? IF ($_GET['shape'] != 'any' ) { $shape = AND hottubs.shape = '%s' } SELECT * FROM hottubs, manufacturers WHERE manufacturers.manid = hottubs.manid AND hottubs.type = '%s' AND hottubs.dimlength <= '%s' AND hottubs.dimwidth <= '%s' AND hottubs.dimhight <= '%s' AND hottubs.seatsto <= '%s' $shape ORDER BY $thesearchtype_search I have only been doing php about a month so go gentle!
View Replies !
Mysql Select Query With Php
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 table in which entry a is smaller than the number (count) of all db entries with criteria x from another table.
View Replies !
Mysql Select Query
PHP Code: <?php include 'common.php' include 'db.php' if(!isset($_POST['register'])) { header("Location=register.php"); } else { dbconnect('rishaorg_members'); } if($_POST['newid']=='' or $_POST['firstname']=='' or $_POST['lastname']=='' or $_POST['address']=='' or $_POST['city']=='' or $_POST['state']=='' or $_POST['country']=='' or $_POST['birthcity']=='' or $_POST['birthstate']=='')........
View Replies !
MySql Query With SELECT
The following query used to work on older PHP. I have upgraded to PHP 4.3.2 and now it stopped working. No problems connecting to db can even print the variables used for search. But it seems as if the variables aren't presented to the query: $result = mysql_query("SELECT username, name, surname, email FROM forums_auth WHERE username ='$_POST[pnr]' OR name LIKE '$_POST[fnavn]' OR surname LIKE '$_POST[enavn]' ORDER BY surname, name ASC") OR DIE ( mysql_error() );
View Replies !
How To Corret This Mysql Select Query?
I convert some code from access to mysql. And I have a InboxMessage table which has From and To field. So, the query is like: select * from InboxMessage where To=12 12 is user id. This query works fine in access. But does not work in Mysql. I think the problem is the field To, which must be a keyword in mysql. So, how to fix this? I don't want to change the field, becuase this will need to change a lot of code.
View Replies !
Is There A MySQL Function Within The SELECT Query....
Is there a mySQL function within the SELECT query that can add all of the data within a field. For example if I have a table called "profiles" and a field within that table called "referals" (which is an integer) and I wanted to add all of the results within that field together... I was trying to think of a loop to write this code in and may still do it but was wondering if there is a function within the SELECT statement that can ADD all of them together.
View Replies !
Very Slow MySQL SELECT Query After 11 Records
I have a very weird problem I moved my database to new IIS 6.0 + PHP 4.3 + MySQL 4.0 setup. I tried to check with myphpadmin if everything works fine, but I couldn't browse my table (125 records). I used SELECT option and found out that SELECT query up to 11 records is ok, but after that, even if I choose to limit query to 12 records, it just hangs. I tried selecting from the beginning of the table and from the middle - same thing, but when I run query localy on mysql console, everything works fine
View Replies !
Drop Down Menu Where The Items Are From A MySQL Select Query
I am just starting programming in PHP and wonder if it is possible to have a drop down menu where the items are from a MySQL select query. I am registering people for a weekend seminar and want to have a list of valid weekends to choose from on the form. Any pointers to scripts or PHP references that will help would be appreciated. I am using the book "Build your Own Database Driven Website Using PHP & MySQL" to get me started, but also need recommendations for a general primer to php.
View Replies !
Mysql SELECT Query That Selects The Latest Items
I am building a website that has a software download category, and has news on the main page. Now I have two tables, named "news" and "software". On the main page I want to select the latest 40 updated items, so whether it is a newspost from table "news" or an extra entry in table "software", or an updated version of an entry in "software". They are all INT types holding a time() string. what I want is a mysql SELECT query that selects the 40 latest items.
View Replies !
Combining 2 Fields In A Single Mysql Select Query
i want to combine 2 fields in a single select query fields. pageheader name values. abcd <div id="d"></div> i want to merge/combine the pageheader and name in a single select query so that it can retrieve the pageheader with some styles which i have stored in another table.
View Replies !
MySQL Query: Select Only Numeric Substring From Varchar Field?
I would like to write a MySQL query that will limit the selected records to a specific pattern that end in digits rather than non-numeric characters. Say the field (TESTPHASE) has values like this A000 APM APM1 A015 A010 A045 HPM1 GPM F020 E045 I want the SELECT query to return only A000 A015 A010 A045 F020 E045 I suppose it would be possible to filter these after the fact with some fancy php code, but I'd MUCH rather do it up front with the MySQL query. Oh, and of course I am stuck with MySQL v3.23.45
View Replies !
Multiple Select From Listbox And Execute A Sql Query Select Statement
Supposing i have a html form with 2 listbox and i name it status and resolution. So it goes <select name='status[]'>... <select name='resolution[]'> Then i have a another php page. $status = $_POST['status']; $resolution = $_POST['resolution']; Now my question is, how do i do the sql query statement? mysql_query("SELECT * from bugs where status=$status and resolution=$resolution"); The problem is, i select 3 options form the status listbox eg. new, closed, duplicate. And from the resolution, i chose fixed, invalid.
View Replies !
Select A Row To Delete/modify
Suppose to have read and displayed (using PHP) a group of row of a DB table on a dinamyc table on a HTML/PHP page. The number of row displayed could be from 1 to n. Each row contains informations and also a cell with a unique ID of the element. I would like to show at the beginning of each line of the table a couple of cells containing two different icons (one for delete and one for modify) so the user could click on it to delete/modify the corresponding row on the DB table. In other word I need to delete/modify the Dbtable row which have the ID of the line where the icon was clicked. This means also that when a icon is clicked I must jump to a PHP routine passing it the ID that appears on the same line of the icon clicked. I have seen a similar method of delete/modify on the phpAdmin program, but I was unable to understand how it work because of the complexity of that routines. To achieve my need I can use, if necessary, also Javascript statements.
View Replies !
Execute An Update Query Based On The Results Of A Select Query
I'm trying to execute an update query based on the results of a select query... This doesn't work - any ideas? This is the code I'm trying to get to run (it updates all products which are set to arrive by a certain date if that date has arrived or passed - and there are products that should and should not be updated in the db this is being tested with...): Code:
View Replies !
Turn Select Query Result Into Hyperlink To Other Query
I have a query which gives results of selecting coursenames from a table called trainingtopics but this does so in a continuous bulk of text without any breaks between each record. my question how do I create line breaks between each record and also how can I force each query result to become a hyperlink which when clicked runs another query that gives details of that course. <?php $user = "root"; $host = "localhost"; $password = ""; $connection = mysql_connect($host, $root, $password) or die ("Couldn't connect to server."); $database = "courses"; $db = mysql_select_db($database) or die ("Couldn't select database."); $sql = "SELECT coursename FROM trainingtopics"; echo $sql."=sql<br>"; $result = mysql_query($sql) or die(mysql_error()); echo $result."=result<br>"; while($row=mysql_fetch_array($result)) { // NOTE this one ABOVE the echo echo "result found!"; echo $row[0]; } ?>
View Replies !
Multi Table Insert Delete Select Function Needed.
I am going nuts here and I know with all the functions out there, there must be an easier way to do this. Maybe someone can point me to the right tutorial or even show me how to do this. I have a $main_id and many $sub_id tables and like to “SELECT to view” INSERT and DELETE those. UPDATE must not be but would be nice. Here is how it looks:
View Replies !
Delete Query
Here’s what I’m trying to do: - Output the last 60 results in my db - works - Delete a record – does not work Can anyone see why my delete query won’t work? It seems to have two problems: 1) It does not delete a record 2) The header re-direct says can’t modify header information Code:
View Replies !
Delete Query Successful
How can I test whether a delete query on any other query for that matter has been successful deleting a record. I tried below but it does'nt return if the query deleted a record. $deletequery= "DELETE FROM details WHERE id='$line[id]' AND orderid='$orderid' AND location='".LOCATION."'"; mysql_query($deletequery) or die(ErrorDB($realname)) ; $message = (!$deletequery) ? 'ERROR' : "<font color='#FF0000'>DONE</font>"; echo "$message<br>";
View Replies !
Simple Delete Query
This code should delete a row from the database where ID = ID however it doesn't seem to be doing its job PHP Code: <? if(isset($_GET['id'])) { Â Â Â Â Â Â Â Â $query = "DELETE FROM mynews WHERE id = '" . $_GET['id'] . "'"; Â Â Â Â mysql_query($query); Â Â Â Â echo "<p align='center'>Deleted</p>"; Â Â Â Â } else { Â Â Â Â Â echo "<p align='center'>Not Deleted</p>"; } ?>
View Replies !
Delete Query Not Working As Expected
I have 2 different php forms. One makes sure that a user has chosen an unique user name (below): $query_rsApp = "SELECT * FROM users where UserName=".$Registered." "; This Select query works right every time (as far as I can tell). I have a form that I want to use to delete user records. This Delete query works fine if the username and password are both numeric... But if the username or password is text, it returns the error "UNKNOWN FIELD 'whatever'" where whatever is my search criteria that I am trying to use.
View Replies !
Delete Query Takes HOURS
why on EARTH would this query: Code: DELETE FROM `test_zip_assoc` WHERE id > 100000 take an entire day when there are 10 million records in this database: Code: +--------------+------------------+------+-----+---------------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------+------------------+------+-----+---------------+----------------+ | id | int(12) unsigned | | PRI | NULL | auto_increment | | f_id | int(12) unsigned | | | 0 | | | zip | varchar(5) | | | | | | lat_radians | decimal(12,11) | | MUL | 0.00000000000 | | | long_radians | decimal(12,11) | | MUL | 0.00000000000 | | +--------------+------------------+------+-----+---------------+----------------+
View Replies !
Select Query With And / Or
Trying to get a search feature running. A table has 2 field 'itemname' and 'itemdescription'. I would like the search to use a keyword on both of these fields but i'm unsure of how to seperate it from the main query. $query = "SELECT " .sellerid . "," . itemname . "," . itemtype . "," . itemstate . "," . itemprice . "," . pic1 . "," . itemid . "," . itemdescription . " FROM item where " . itemtype . "= '$ctype' AND " . itemstate . " like '$stype' AND " . itemprice . " >= '$lprice' AND " . itemprice . " <= '$hprice' AND " . itemdescription . " like '%$kwords%' OR " . itemname . " like '%$kwords%' ORDER BY `itemprice` DESC LIMIT $offset, $rowsPerPage"; The OR seems to be working on the whole query not just the last little bit like i would wish. " . itemdescription . " like '%$kwords%' OR " . itemname . " like '%$kwords%' Something like this but contained in the main query? Does this make sense?
View Replies !
Select * From Query
Im trying to run a simply Select * from query but the result is a blank page. here is my code. when I connect to the db using the same code but inserting data I get no problems. so Im having no server problems. <?php $user = "root"; $host = "localhost"; $password = ""; $connection = @mysql_connect($host, $root, $password) or die ("Couldn't connect to server."); $database = "courses"; $db = @mysql_select_db($database, $connection) or die ("Couldn't select database."); $sql = "SELECT * FROM trainingtopics"; or die (mysql_error()); ............................
View Replies !
Query SELECT * FROM
here is my query to my database $result_pi = mysql_query("SELECT * FROM players WHERE teamid = '".$gm_team2."' AND position != 'G' and status = 'Healthy' AND registered = Ƈ' ORDER BY lname"); this works fine, but i am trying to add in as well status = 'Rookie' When i try and add this, both the status things work against each other. How can I get this query to bring up both of them.
View Replies !
Select Query
However when I echo mysql_num_rows it gives 0 results even though the same date is in the db table. class_date is set as date type in mysql db. PHP Code: $query = "SELECT * ". "FROM class ". "WHERE class_date = $class_date";
View Replies !
Select Query
I have a table with 2 fields, lets say field1 and field2: Now I have records in that table something like this: 1 a 1 ab 2 a What I need is to make a selection and the result returned to be something like this: 1 a;ab 2 a So, I want for the same field1 to concat field 2 using a separator (ex. ‘;’). Mysql server version is 4.0.
View Replies !
Select Query Problem
I use php4 and winxp. This query works as expected: $result = mysql_query(" SELECT feventid, UNIX_TIMESTAMP(fdate) as fdate, ftitle, fpostedby, fdetails, factive, UNIX_TIMESTAMP(fpostdate) as fpostdate FROM events WHERE fdate between '$datefrom' and '$dateto' and factive and fpostdate <= curdate() ORDER BY fdate, fpostdate "); However, when I add the condition !(strpos(fdetails,'$fsearchstring')===false), $result is false. $result = mysql_query(" SELECT feventid, UNIX_TIMESTAMP(fdate) as fdate, ftitle, fpostedby, fdetails, factive, UNIX_TIMESTAMP(fpostdate) as fpostdate FROM events WHERE fdate between '$datefrom' and '$dateto' and factive and fpostdate <= curdate() and !(strpos(fdetails,'$fsearchstring')===false) ORDER BY fdate, fpostdate "); Even simpler stuff like: 'and strpos('abc','c')>0' does not work. I made two more discoveries trying to crack the problem. Ɔ=0', is an acceptable condition, while 'true' is not. For the first query, $result does not return true, but 'Resource id #3'. I have just started with php. What am I doing wrong?
View Replies !
Select Query For Keywords
I am connecting to an Access database. I have the following code that breaks the user submitted title into an array. I want to match only records that have only the array values, but can be in any order. For example: User enters - "Purple People Eater" Matching Records - "Purple Eater People", "Eater People Purple",... but NOT - "The Purple People Eater", "Purple People",... Here is my code: PHP Code:
View Replies !
Select Query / Loop
My users are organised in a table named 'users'. Each user is a member of a department, but some users are members of more than one department, so I have another table named 'user_department'. I have another table named 'submissions' int which users submissions are stored. Right now I am developing an archive of submissions. Generally speaking a simple query will do the job like this: $query = "SELECT * FROM submissions WHERE status != 'Pending' AND sid = '$username' ORDER BY id desc LIMIT $from, $max_results"; $result = mysql_query($query); The problem comes when I try to select only the submissions lodged by the users department. The point being that the department head can view all submissions lodged by his department. If the department head is only head of a single department, this would work: $query = "SELECT * FROM submissions WHERE status != 'Pending' AND department = '$users_department' ORDER BY id desc LIMIT $from, $max_results"; $result = mysql_query($query); But if the department head is head of more than one department, I start to get lost! I can loop through the 'user_department' table to find out which departments the user is the head of like this: Code:
View Replies !
Php Query To Select Min Date
im trying to get a minimum date from my database, the current way im doing it is: SELECT * FROM events where Date > NOW() OR Date = '9999-12-12' ORDER BY Date ASC LIMIT 1 this works in terms of code, but it doesnt do what I want it to do. Its the ORDER BY Date, that is the problem: What I want to select is The next date OR a date = 9999-12-12 I tried searching for a query like "select MIN date" but couldnt find anything on it, plus the date has to be in the future, hence the need for DATE > NOW() quite confusing I know!! but any advice?
View Replies !
Select Menus Query
I have created numerous select menus where the user can if they so wish select all or any one of them. At the moment my code insists that they always select at least the subfund menu. How can I set it up so that they can select any one menu? Code:
View Replies !
Problem With Select Query
This script/function tests properly when using DreamWeaver's Testing Server and Live Data Settings, but fails on the live Web Server, giving the following error. Code:
View Replies !
Select Query + Inner Join
I have 2 tables: keywords{keyword_id, keyword} url{url_id, url, keyword_id} I have a search form where the user enters a keyword and if it is similar to the keyword(s) in database it should return the url. Code:
View Replies !
Reconfigure A Select Query
have a query that I want to display in a table format on a web page. I call up the following recordset. Name, Color and Rank are the fields. The results of the query are: Name -Color -Rank Jim--Orange --1 Bob-- Red ---1 Sue --Blue ---1 Jim--Yellow --2 Bob- Green --2 Sue -Purple-- 2 I want to reconfigure the above results to display in a table format as follows: Rank- Jim -Bob -Sue 1 - Orange--Red- --Blue 2 --Yellow -Green- Purple Notice that I want the individual names to be the column headings. I'm not sure how to approach it. Another forum recommended converting the query into an array, but after much head banging and research I'm not sure how to do it.
View Replies !
Select And Update In One Query
If I have a simple select query that select everthing in a row like SELECT * FROM profiles WHERE ..... can I also make a update in conjunction with the selection? Like 'column+1' so I will get a field telling me how many times a specfic rowID has been viewed? What about speed? Is there any difference in running two queries right after each other or running one query with a combined select/update?
View Replies !
Select Query From 2 Tables
I have 2 tables, both of which contain a feild which holds an id number. table = int_bookings feild name = booking_id, TYPE =int feild name = course_id, TYPE = int table int_courses feild name id, TYPE = int I want to call records from the "int_bookings" table using the "booking_id" and show all the feilds along with the record from the "int_courses" that has the same "course_id". Code:
View Replies !
Multiple Select Query
I'm trying to make a page where you can view all users or narrow them down by country. The problem I'm having is selecting several countries. In other words intead of finding users from either country 1 or country 2 I want to be able to see users from countries 1,3,4,9,32. Code:
View Replies !
|