Query Condition Didn't Get Logged
In slow query log query condition didn't logged. Only query with table name omitting condition get logged. What is the reason. How to log the entire query.
The following query takes 2s to execute and is logged in slow query log. The original query is :
Select count(*) from markingqc where persondate between '2007-07-09 00:00:00.000' and '2007-07-09 23:59:59.999' and PersonName='admin'
Logged query is:
SELECT * FROM markingqc;
How to get the condition in the log?
View Complete Forum Thread with Replies
Related Forum Messages:
Query To Show Users Who Haven't Logged In
Since this would seem to be an easy question, I'll assume it's been answered here before. On a site of mine, every time someone logs in, authenticating against 'Users', a record is inserted into a table called 'UserLog'. The two tables below represent the basic structure of what I'm working with. Table: Users -------------------------- ID | Username | Password | -------------------------- 1 | syeargin | testpass | 2 | rdoe | passwd | 3 | jdoe | demo | 4 | jking | passwd | 5 | badams | demo | -------------------------- Table: UserLog ....
View Replies !
Phpmysql Query, Delete All People Not Logged In
I wish to run a sql query on my databse Delete from Table: customers AND Table: customers_info Where customers_info_id AND customers_id are the same and customers_info_number_of_logons = 0 This will remove all users that have not logged on, I would like to run this as a cron job as well but one thing at time....
View Replies !
More Than 1 Condition In Same Query
I want to select the table and then order it by the start-date which is one of the column and check if the the start date is gone as in start-date > current_time(the time when the query is performed) and then report the relevant top 3 results!
View Replies !
Query Based On 'does Not Exist' Condition
Let's say I have a table called 'forumtopics' with a field representing the topic author's username. I then have another table called 'ignorelist' which has two fields; one is an account number and the other a reference to the aforementioned author. There can be many ignored authors for any one account. For any given account number, I'd like all the rows from the forumtopics table where there is no match for (account, author) held in the ignorelist table. Obviously it's easy to check for existence but can the opposite be done? I run MySQL 4.0.17.
View Replies !
Query To Ignore Results If Condition True
I am having trouble defining a query that ignores rows if a query if true IE. Column 1 = 1,2,3,4,5 Column 2 = a,b,a,a,c For example: I search for results from column 1 and if '3=a', ignore all 'a' rows thus returning the result b=>2, c=>5.
View Replies !
Can't Get Logged In
I've installed the latest version on windows xp. Set the root password. Brought up mysql administrator and entered root localhost sa my password It says access denied for root@localhost (using password YES) What do I need to enter here to make this work?
View Replies !
CANT GET LOGGED IN
I just installed the software and i am trying to get access to the mysql database so that i can add a user and grant permissions but everytime i try to issue a command it comes back to me with. Error 1044: Access denied for user: '@localhost' to database 'mysql' I am running the software on my machine and trying to access it from my machine, i just cant seem to get into it. What am i doing wrong?
View Replies !
Showing Users Logged In
I am trying to get a query that will return a list of users currently logged in. I have a table called table_users, in that table there are are several fields, which I have displayed below.
View Replies !
Last User Logged In, With DATETIME
i am trying to after Log In succesfully send the DATETIME to a field on my table to have the date and time stamp on the last user logged in. I dont know how to incorporate the command into my code, the Insert Value code: ....
View Replies !
Where Are Remote Connection Errors Logged?
The server machine accepts most connections, but wont accept connections from a version of mysql on another machine that was hand compiled to work w/in SGE. Instead it reports the following error: ERROR 2003 (HY000): Can't connect to MySQL server on 'billy.bio.nyu.edu' (111) However, when using a package-install mysql client on that same client machine, we can connect w/o issue.
View Replies !
Different Data In Same MySQL DB Depending On Which AD User Is Logged On
- I tried MySQL Essentials 4.1.12a and 5.1.33 (latest version so far) - There is a server where multiple users login with their AD accounts via remote - There is an application which uses a certain MySQL database - This MySQL database is automatically created during the application's installation - Most of the user-specific settings for the application come from these database entries - There cannot be multiple databases / instances / installations; the scenario is restricted to this single one - It will be made sure that though multiple users can remote access the server simultaneously, just one of them can access the application at a time => I want the application settings and therefore the database content for every AD user to be unique! Failed solution: - I created a folder named "Database" - Below that folder I created a subfolder named after the username of every user - The logon script assigns the respective folder as drive S for the users - Example: For user Larry I created the Folder "DatabaseLarry". When Larry logs in, this folder is mounted as drive S - Next I copied the database files ("All UsersMySQL<DBNAME>" or something, not sure about the very exact path now) to the user's virtual S drive - Then I tried to teach MySQL that it should pick up the database from the S drive instead (so the path stays the same everytime, but the content changes depending on who's logged in) - Result: SQL Service would not start anymore - Installing the instance or even the whole MySQL application onto the S drive failed in the same way
View Replies !
Incorporate An Additional WHERE Condition (was "Help With My Query Please?")
I’m trying to incorporate an additional statement in the below query, which works: $sql = "SELECT b.bookID, b.roomID, b.arrive, b.depart, b.status, b.property_id FROM room_booking_two b WHERE ((b.arrive BETWEEN '$d1' AND '$d2') OR (b.depart BETWEEN '$d1' AND '$d2')) ORDER BY b.roomID, b.arrive"; Now I want to add the line: WHERE b.property_id=".$_GET['property_id']) So I thought it would work like this: $sql = "SELECT b.bookID, b.roomID, b.arrive, b.depart, b.status, b.property_id FROM room_booking_two b WHERE b.property_id=".$_GET['property_id']) AND ((b.arrive BETWEEN '$d1' AND '$d2') OR (b.depart BETWEEN '$d1' AND '$d2')) ORDER BY b.roomID, b.arrive"; But that does not seem to work. Can anyone please advise?
View Replies !
Query Won't Use Index On "OR" Condition
I have a table full of teams: Code: team_id, name And a table full of fixtures: Code: fixture_id, home_id, away_id, date The fixtures table is now quite large and this week I added indexes on the "home_id" and "away_id" columns (in addition to the existing primary key on fixture_id). I run a query which joins on the following: Code: JOIN fixtures ON (fixtures.home_id = teams.team_id OR fixtures.away_id = teams.team_id) But it does not use my indexes for the join.... it therefore scans around 40,000 rows. If I remove the "OR fixtures.away_id = teams.team_id" and just join the home ones, the number of rows scanned goes down to 11. Is there a reason that the "OR" operator stops the index being used? Do I need to re-write my sql so that it searches 11 rows twice (one home, one away) instead of doing the "OR" clause?
View Replies !
Where Condition
I want to query my database like so... $query = "SELECT * FROM wines WHERE restid =1 AND site_id_sask =1 ORDER BY name"; The only hitch is that in the restid field I would like to hold more than one entry. Meaning for some entries I would like to have the values 1, 2, 5, 9 for example. In another entry I may want to have 1, 5, 8. Can I search this the restid field?
View Replies !
Using IF Condition
I want to do a query that first checks whether 2 items are similar, and if they are, uses conditon A, and if it doesn't, uses condition B. For example: SELECT * FROM table IF(A = B, WHERE A > 10, WHERE B > 10) So if A = B, the query will be: SELECT * FROM table WHERE A > 10 and if A != B, the query will be: SELECT * FROM table WHERE B > 10
View Replies !
Like Condition
How would I select everything that starts with a and b from the name column in the persons table? I know how to get it for just people starting with a- SELECT * FROM persons WHERE name LIKE 'a%' But how do I do a and b?
View Replies !
If Condition Help
SET @RecordCount = 0, @PageCount = 0, @PageNumber = 0, @PageSize = 0; SET @PageSize = 10; IF(1 > 1.0) THEN SET @PageCount := (@RecordCount / @PageSize) + 1; END IF;
View Replies !
If...else Condition
I have a table - mytable and the columns in the table are as follows: CityName (varchar) updated_by (varchar) added_by (varchar) The first column is a city column, someone would add/update the city names and accordingly their name would be updated/added to the updated_by and added_by columns. Now, the condition of my query would be: - if the updated_by column is NOT empty and the added_by column is empty, then the value of the updated_by would show . - if the added_by column is NOT empty and the updated_by column is empty, then the value of the added_by column would show. - if both added_by and updated_by columns are NOT empty then the value of the updated_by would show.
View Replies !
More Than One Condition In A HAVING Clause
I have tried to run a query where the reuslts are restricted by a HAVING clause with 2 conditions, but the second condition seems to be ignored. for example SELECT userid, AVG(position) FROM `table1` WHERE (status='finished') GROUP BY userid HAVING (COUNT(*) >= 4 AND AVG(position) < 5.5) returns exactly the same as SELECT userid, AVG(position) FROM `table1` WHERE (status='finished') GROUP BY userid HAVING (COUNT(*) >= 4) even though there are values for AVG(position) returned that are > 6. Is it the case that I can't have more than one condition in a HAVING clause? have I got the syntax wrong? Is the behavior different in a later version? I am using "mysql Ver 11.15 Distrib 3.23.41, for redhat-linux-gnu (i386)"
View Replies !
Condition In CONCAT
i have three fields of name in database named as fnam,mname,lname. fname and lname is mandatory field and mname is optional. i want to make a search query on name Expand|Select|Wrap|Line Numbers
View Replies !
Insert If Condition
I am trying to optimise my application. One of the parts of it is inserting a value into a table if the number of rows in that table with the same `date` field as the row to be inserted is less than 24 So currently I do two statements, one to check the number of rows and another to insert. Is there any way to INSERT something if condition. I have looked as CASE but it does not seem to do what i want. So a mock up would be: Code: SELECT COUNT(*) FROM `table` WHERE `date`='2006-01-01' If the value is < 24 INSERT INTO `table` VALUES (...)
View Replies !
Join Condition
i have 2 tables users relations in the table relations i record relations.user_id and relations.connection those two fields refer both to the same id in the users table. Now to the problem: I want to do a query for one user, and find his friends, therefore i have to search both fields in the relations table, and then depending on where his id was found select the counterpart. (if his id was found in the relations.user_id i need the relations.connection and the other way round...) now i do not only want the id of the friend but i would like to pull his details from the users table.... to be honest i tried a few things but i need a hint whether this is possible or whether i need two queries... or maybe a subquery.
View Replies !
Condition Preferred
Imagine a table of company addresses. A single company can add many addresses and edit them. A company can mark one and only one particular address as Primary. I want to do a select query as follows: if the company has a marked Primary address then select it and no other address, else select all addresses (perhaps with some additional conditions) for that company The query would give just one result for some companies and a number of results for others.
View Replies !
WHERE Clause Condition
I've had a bit of experience with MySQL and pgSQL databases and have never seen this type of thing before: Code: SELECT * FROM users WHERE id This is just an example, but the point is what happens when the condition in the WHERE clause does not equate to anything? ie, shouldn't it be 'WHERE id = X' or something like that? The query in question doesn't produce any errors, so is there something I've missed??
View Replies !
Multiline Condition
there's something that I don't manage to do with mysql exemple : I've a values list like (22,3,12) I've a table like : idx | idy ---------- 6 | 22 6 | 3 5 | 22 5 | 1 6 | 12 So, from the values list, and with only one request, I'd like to get the value "6", in this case, the value that is recored with each values of the list.
View Replies !
Index With Condition
Will a table index run faster depending on the order of the columns in it? My table has 500k rows and 600 columns. The search and sort queries run on subgroups: order by ssn where ssn like %555% and group = 2; But these queries are _very slow. Do I create an index on group, ssn and lname, group? Or add more memory allocation to MYSQL?
View Replies !
If Condition In View
Basically i want to add put a where condition in a view if the user variable '@org_id' is > 0. Here is some pseudo code: CREATE VIEW view_students AS SELECT * FROM students If (@org_id > 0) THEN WHERE org_id = @org_id END IF I've tried lots of different approaches but i just cant figure out how to do it.
View Replies !
Double Condition
I have a relatively straightforward SELECT statement but am running into problems: SELECT sons.id FROM sons, fathers WHERE (sons.father_id = fathers.id AND fathers.name = 'Bill') OR (sons.father_id = -1); So essentially I want to select all sons with a father called 'Bill' or with no father i.e. father_id is -1. This works fine without the last line, but when I add the last line in, it outputs duplicate rows of each son for every entry in the fathers table. As I understand it, this is because I'm referencing the 'fathers' table in the FROM statement but if the father_id is -1 then there's nothing to join the two tables on. How do I get around this? I'm at a loss.
View Replies !
Insert With Condition
would like to check if data exists in my database, if no then insert it to my database: insert into table (column1,column2 ,colum3) values (value1,value2,value3 ) where(column1<>value1);
View Replies !
Nested Condition?
I'm just getting trouble making a query that should be like this: SELECT * FROM table where [cond1...] AND [cond2...] AND ([cond3...] OR [cond4]); In fact I need to verify if certain value is in one column or another.
View Replies !
Condition Practices
is it better to have conditions for joining tables in the WHERE section of a query string rather than the ON part of the LEFT JOIN part when there are multiple conditions? The reason I ask is I have a query string with multiple (17 to be exact) joins and a few of them are farily big tables, and I had mysql-nt crash when I had 2 separate conditions on 1 of the left joins. I moved one of the conditions to the WHERE section and the crashes seem to have stopped. I pinpointed the crash to 1 LEFT JOIN that has 2 conditions tied to it so I made a snipped version of the string that still crashed it: SELECT * FROM tblinvoices inv LEFT JOIN tblinvoicedetails invd ON invd.invoiceid=inv.ID LEFT JOIN tblrelpatternfit pf ON pf.patid=invd.descid AND (pf.fitid=invd.fitid OR pf.fitid IS NULL) WHERE invd.invoiceid=$intid OR (invd.invoiceid IS NULL AND inv.ID=$intid); This string crashes it everytime (because of the tblrelpatternfit part). I checked the table with check table just to make sure it wasn't corrupted and it was OK. When I moved the 2nd condition on the tblrelpatternfit to the WHERE at the bottom it stopped crashing, but I wanted to see if this was a known problem (v5.1.11) or just me being a noob. Just as a side note, there are other LEFT JOINs in this query that work fine with 2 conditions, but the tables aren't as big as that one is.
View Replies !
Use A Result Set As A Condition
I have two different tables in my database. One is a relationship table defining parent/child relationships between my data items. Here's a simplified example: ID1......ID2 ..1.......101 ..1.......102 ..1.......103 ..2.......104 ..2.......105 --etc-- The other includes a field that has the the name of each item. Another simplified example: ID........Name ..1........Animal ..2........Plant ..101......Monkey ..102......Dolphin ..103......Eagle ..104......Grass ..105......Sunflower --etc-- My task is to find the IDs and Names of all the children of a given ID. Getting all the childrens' IDs is easy. Here's the query I'm using: SELECT ID2 FROM RelTable WHERE ID1 = [given ID] But to get the names of all the IDs returned in the result set, I have to make a query to the name table for each row returned. So if I get 300 children, that's 300 separate queries to the name database, which is slower than I'd like. Is there any way to do this with a constant number of queries?
View Replies !
Using <= Condition In Formula
I have a SQL formula as below. Manifest.Weight, GREATEST(Manifest.Weight, (((Manifest.U * Manifest.L * Manifest.B * Manifest.H) + (Manifest.U1 * Manifest.L1 * Manifest.B1 * Manifest.H1)) / (Manifest.Factor)) As `Greater of DIMMS & Weight` With the alias result I need to determine in which catergory it will be as below. Client.`0to20KG`, Client.`20to30KG`, Client.`30to40KG`, Client.`40to50KG`, Client.`50KGplus`
View Replies !
Previous To Last With A Certain WHERE Condition
How do i fetch the previous row record with the same WHERE when the last record has only a lately date. for example field CConsorcio CRubro ImporteA FechaA 1 105 1000 2006-05-10 2 110 30 2006-05-12 5 105 300 2006-05-13 4 104 600 2006-05-14 2 103 800 2006-05-15 the WHERE CConsorcio=2 the last record: 2,103,800,2006-05-15 and i want to select the row: 2,110,30,2006-05-12
View Replies !
SORT BY With Condition?
is there a way to do sorting depence of some condtion directly in the MySQL query? for example, I have this query: SELECT cat_id, cat_name, cat_date, cat_parent FROM categories ORDER BY cat_name ASC but I'd like change sorting if cat_parent = 23 for example. so, is there a way use something like: SELECT cat_id, cat_name, cat_date FROM categories ORDER BY ((IF cat_parent = 23) THEN cat_date ELSE cat_name) ASC I dont know MySQL at all, so this is just an example of condition idea that I'd like to use.
View Replies !
Search Condition
I like to call all teachers except math teachers. I mean that every registered members who entered his job as teachers, but exclude(minus) math teachers. It would be something like below WHERE job like '% teacher%' and job like '% ! math%'.
View Replies !
Order By If Condition
I'm trying to return a list of products, where the top of the list will be one of 2 products, the choice being randomly selected. I tried a rand() condition in the ORDER BY clause, which partly works, but of course the rand() function is evaluated for every row, so it doesn't give the consistent results i need. SELECT productID, prodName, adMessage, nPrice, nPrice*(1+vatRate) as salePrice, showSale, originalPrice, pic.picType, pic.ordering FROM tProducts p JOIN pictures pic ON p.productID=pic.relProdId and pic.picExists = 1 JOIN taxCodes tax ON p.taxCode=tax.taxCode WHERE p.featuredProduct=1 AND p.stocklevel>-3 GROUP BY p.productID ORDER BY productID=if(rand()<0.5,117029,117035 ) desc, rand() LIMIT 10 .
View Replies !
Update On A Condition?
I was wondering if its possible to do a different update based on a value in one table - specifically if I have: table1 -T1_ID -T1_Image -T1_AdditionalImages (Bool) and table2 -T1_ID* -T2_Image obviously a v.stripped down version of my data structure, where the underlined T1_ID is a primary key, and the * is a foreigh key. The logic behind it is that an item can have multiple (0..*) images - T1_AdditionalImages indicates whether there could be more images for this item in table2 (it is set to true when the item has 1 image added). Now what I'd like to do is check whether T1_AdditionalImages is true, if it is true, then INSERT a new entry to table2 with the relevant details, if it is false then UPDATE table1.T1_Image to be the image details, and table1.T1_AdditionalImages to true.
View Replies !
Order By Condition?
The query below is a union of 3 SELECT statements. The only difference in each one is the value of 'submission_views.timestamp' in the WHERE clause. This query is very long and I want to shorten it. Would it be possible to combine all 3 statements by sorting the records by WHERE conditions? The records where the timestamp is within the last 7 days would come first, followed by the ones where the timestamp is older than the last 7 days, then finally the records where the timestamp is NULL.....
View Replies !
Wrapping A Condition
Would mysql interpret this query properly? ...WHERE type_id='$type_id' AND cat_id='$cat_id' OR maincat_id='$maincat_id' AND item_activated='1' I have a GET var that will get either cat_id or maincat_id but all other conditions apply,i want something like this: WHERE type_id='$type_id' AND (cat_id='$cat_id' OR maincat_id='$maincat_id' ) AND item_activated='1'
View Replies !
Mysql WHERE Condition Execution
I have 2 columns and I search rows with two conditions. SELECT * FROM table WHERE A = '$a' AND B = '$b' How can I make mysql search columns with A condition first and after that within these condition B. I would like to know, how mysql search works. How can I tell mysql how to search?
View Replies !
Do Update With IF Condition... In MySQL
Example: In MYTABLE I have three columns, like this: ID(INT), PUBLISH(ENUM(Y,N)), PASSWORD(VARCHAR(10)) This is what I want to do: UPDATE the tablerow with id=333, SET publish='Y' IF password='xxx' I was trying out the MySQL-expression "IF(expr1,expr2,expr3)" but this really doesn't do it! It could work if it was possible to set a SELECT statement in expr1, returning NULL or EmptyString. Then if NULL DO(execute) expr2 ELSE DO(execute) expr3 Like this: IF(SELECT * FROM mytable WHERE id=333 AND PASSWORD='xxx',UPDATE mytable SET publish='N' WHERE id=333, UPDATE mytable SET publish='Y' WHERE id=333 )
View Replies !
Delete With Data Condition
I have a table with a ton of rows but I only want to delete all the rows after the following date. 2008-09-03 18:55:09 All the dates before that are in the year 2007 so how can I form a statement which deletes from the column "DataEntered" with any dates before 2008. Just out of curiosity how do I make the condition after the DELETE to ignore the seconds and such so that it only needs to read 2007-11-18 and ignores 16:27:41
View Replies !
LIKE Condition For An Exact Match?
I have a field in a table called Title. I have a record whose Title field contains a value of Ford Mustang. When I run a LIKE on my table such as LIKE 'Mustang' my record does not shop up. I am assuming LIKE is for an exact match. What if I want any record that has EITHER Ford or Mustang in the Title.
View Replies !
|