Max(count(*)) Usage?
I have a table with a structure along the lines of
customerId
itemId
copyId
which form a primary key.
I want to know the max occurence of a particular item, based on copyId.
Ie, if 5 customers want itemId 6, 3 want copyId 1, 2 want copyId 2, should return 3 for itemId 6..
I thought something like
select itemId, max(count(*))
from items
group by itemId
might work, but alack, not the case.
Suggestions in how to do this with one query?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Count Query Causing "excessive Processor Usage"
For the second time in the past 6 months my hosts have shut down my site because it was apparently causing a shared mySQL 5 server to max out at 100% usage. I'm not much a programmer, know even less about mySQL and obviously don't have access to the server from the back end but I'd appreciate any advice as to whether it is my query that is causing the problem: Set rsMail = objConnC.Execute("SELECT * ,(SELECT COUNT(*) FROM comments WHERE comments.submissionID = submissions.submissionID AND comments.commentInclude = 1) as CommentCount FROM submissions WHERE PigeonHole = 'mailbag' AND Status <> 'hold' ORDER BY submissionID DESC LIMIT 20") Apart from two instances, this query has been working fine on a page that receives between 10,000 and 30,000 visits a day. The site is running on Windows and coded in ASP but is calling a separate mySQL server.
/tmp Usage
are there any best practices for /tmp on a std *nix install for MySQL, and if so, what are they ? Also i can't seem to find any more information on what specifically you'd require a LARGE /tmp for in MySQL.
C# Usage
Does anyone know if C# will work with mysql??? I know it does C++, but I don't know if the connectors or whatever are out there for C#
MAX() Query Usage
I have a database of marks and I need to find out the maximum mark taken by each student in any subject. For example If am a student and I have got 60 in Language, 70 in Maths, 80 in Science and 90 in Social Studies, I would need the result "90" and the relevant Social Science subject to be displayed so that I know am good at Social Science of all the subjects. Likewise, my friend got 65 in commerce, 70 in accountancy, 80 in economics and 90 in Applied Maths. As you may see here, the subjects are all different in both these cases. I only need to know this following result That I am good at Social Studies and my friend is good in Applied Maths. The table name is marks. The fields are subject_id, mark_obtained, student_id. When I try this query. Select subject_id, max(mark_obtained) from marks group by student_id In this case, I get the correct maximum mark, but the subject id displayed is incorrect. Can anyone tell me what am doing wrong here?
Getting CPU Usage Of A Query
There are some various queries running on my site that appear to use a whole lot of CPU resources under certain conditions which I haven't identified. Is there any way I can see which queries are using up how much of the CPU instead of just being able to see the general process id for MySQL? I use cPanel and WHM to manage the server.
Index Usage
I have two tables, one is Student, which has studentid, personid, grade, fees as its columns. The other one is Person, which has personid, firstname, lastname, address as its columns. When given a studentid, I need to get the student' info, such as lastname from the db tables. I can do it with two queries as the following: 1. mysql> select personid FROM Student where studentid=1; 2. mysql> select lastname FROM Person where personid="the id I got above"; Or I can do it with one query: 3. mysql> select p.lastname from Student s, Person p where s.studentid=1 AND s.personid=p.personid Both works. However, I can't tell which one is actually faster, since MySQL shows me "1 row in set (0.00 sec)" for all these three queries. Both studentid and personid are primary keys, so they are automatically indexed. Will both indexes be used in query number 3? I saw people said that MySQL could use in a query only one index...Does it mean only one index will be used in query number 3? I am wondering which one will give better performance.
Counting Usage Per Day
I want to record how many times an application is used in a day. Is it possible to create a table with a date field that automatically creates a new record each day with the present date as the primary key.
Memory Usage
I've been analysing the memory usage of our server and each SQL thread seems to be taking up 10mb - since our site is basically a search site that means we're using 10mb per user which means with our 2gb RAM we can take around 120-200 simultaneous visitors. Other than buying more RAM, what can I do to increase the number of simultaneous connections (ie - how can I reduce memory usage?) By my Calculations we need to be able to accept around 500 simultaneous searchers to meet our target. We will also be increasing the amount of data we have - currently it is around 1.5 million records but that will be gradually increasing to around 10 million - which I'm sure will also increase the memory load on the server. Right now we have 1.4Gb Data and 380Kb overhead.
CURRENT_DATE Usage
I am trying to access some data from a database based on the date. here is the SQL: SELECT internallocation.LocationName, breed.BreedName, animal.DateBroughtIn from breed, animal, internallocation where (breed.ID = animal.BreedID AND internallocation.ID = animal.ShelterLocation AND animal.DateBroughtIn = 'CURRENT_DATE()') This command returns no results... however, if I put in the date like so: SELECT internallocation.LocationName, breed.BreedName, animal.DateBroughtIn from breed, animal, internallocation where (breed.ID = animal.BreedID AND internallocation.ID = animal.ShelterLocation AND animal.DateBroughtIn = '2005-06-24') I get the results I am looking for. How can I use CURRENT_DATE to create a report based on the date, so the SQL does not have to be edited every time to change the day?
Wildcard Usage
Here is an example of the code: $query = "SELECT * FROM table WHERE field = '*' "; I want to return all the fields from the table where the field is any. The program is a little more complicated than this. Basically using a dropdown menu, the user can search all, or a particular field. If they select "search all", I need the ability to insert that into the query statement.
Memory Usage
We have Mysql 5.0 running on RH linux. We have noticed that the swap memory increases but never gets released unless we reboot the server every 2-3 weeks. How would I know whats using this swap memory? Second question which I think maybe related to the first is that mysql is using a lot of memory when I do a top. Is there a way to limit the memory usage of mysql? I have a large table in mysql about 7 GB and I have 8 GB physical memory and swam is set to use 2GB.
MySQL 4.0.xx Admin And Usage
I've recently taken over my non-profit's Web site design, administration and maintenance with relatively little MySQL experience (although I have learned a great deal very quickly). My question is, does anyone know where I can get a manual or something like the current manual "Building your Own Website Using PHP and MySQL .."(ordered from sitepoint.com site). This manual is basing the MySQL on the most current version of 5. I'm looking for something similar that addresses the 4.0.xx(27 specifically) of MySQL
LEFT JOIN Usage HELP!
Schema: Table1 -t1field1 --> primary key -t1field2 -t1field3 Table2 -t2id -t1field1 --> foreign key of t1field1 -t2field2 -t2field3 -t2field4 Database Values: Table1 row1: 1,aaa,123 row2: 2,bbb,123 row3: 3,ccc,123 row4: 4,ddd,123 row5: 5,eee,123 Table2 row1: 1,1,aaa,123 row2: 2,1,jjj,123 row3: 3,1,aaa,123 row4: 4,2,hhh,123 row5: 5,3,hhh,123 row6: 6,2,aaa,123 row7: 7,1,jjj,123 Query: SELECT t1.t1field1, t1.t1field2, t1.t1field3, t2.t2field2, t2.t2field3, t2.t2field4 FROM Table1 AS t1 LEFT JOIN Table2 AS t2 USING(t1field1) WHERE t1.t1field2 = 'aaa' Question: Where do I insert a "WHERE clause" if i wanted to get t2.field2 with a value of 'jjj' only? or my query is totally wrong.
High CPU Usage (99.9%) On RHEL4
i need your help on this issue. I am running a web server in my orginazation internally with mysql-4.1.12 and RHEL4. Now, its been only one day and using 'top' command its showing mysqld process using cpu 99.9% constantly. This is used by say around 4000 users. My my.cnf file : [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Default to using old password format for compatibility with mysql 3.x # clients (those using the mysqlclient10 compatibility package). old_passwords=1 [mysql.server] user=mysql basedir=/var/lib [mysqld_safe] err-log=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid output of mysqladmin version .......... ... Threads: 53 Questions: 324297 Slow queries: 588 Opens: 39976 Flush tables: 1 Open tables: 64 Queries per second avg: 67.788 output of mysqladmin extended-status Variable_name | Value | +--------------------------------+------------+ | Aborted_clients | 742 | | Aborted_connects | 35 | | Binlog_cache_disk_use | 0 | | Binlog_cache_use | 0 | | Bytes_received | 29401860 | | Bytes_sent | 1049908921 | | Com_admin_commands | 2352 | | Com_alter_db | 0 | | Com_alter_table | 0 | | Com_analyze | 1 | | Com_backup_table | 0 | | Com_begin | 0 | | Com_change_db | 40895 | | Com_change_master ...................................................................
Analyze Index Usage
I am running a SELECT query that is taking approx. 200+ seconds to complete. I believe I have the tables indexed properly, but apprarently not. How can I determine what indexes a query is using and evaluate the execution plan (as you would in MSSQL)?
CPU Usage Issues On A Windows Box?
As the site receives over 50 simultaneous hits, mysql uses up just about all cpu usage... I have fine tuned everything - can any one offer any suggestions or share similar experiences??
Can I Limit Ram Usage In MySQL?
I just had my server shut down because my hosting company said I was using 350 to 450 megs of ram. This seems nuts to me as I'm only running a shopping cart with about 1000 items with only about 50 visitors per day. Since they installed mysql on the server, I asked them why they hadn't configured it to work with the parameters of their system. Their response: "Unfortunately, there is no way to limit the RAM usage for mySQL. I apologize for the inconvenience this may cause however there is no way to do this." Do they know what they are talking about???
Orders Table - 100% CPU Usage
I'm starting to dive into something that looks like a PHP/MySQL issue that is bogging me down (PHP5, MySQL 4.1, Apache 2 on a Windows XP ws). (At the end of this message, the PHP code) We operate a virtual store and there's this administrative tool, loaded by the code included, which lists orders by category (new, shipped, cancelled etc.); on the top of the page, it first shows each category's totals (3 new, 18 shipped etc.). Obviously, these data comes from an "orders" table which, as of today, has 8.103 records. I did increase already cache and buffer sizes on PHP and that helped tremendously to load the tool *if data doesn't change* in between. When it does, the following happens: 1. CPU usage goes all the way up to 100%, and 2. it takes approx. 45-60 seconds like that until the page ends loading. I'm no PHP programmer, but it seems to me this has to be related to the code below. Code:
Lowering Memory Usage?
I was wondering if there's any way I can lower MySQL's = memory useage? It often uses more than 50000kb which I consider to much.. I'm guessing I should play with my.cnf or whatever it's called (located at = C:/ and windows calls it cardnumber or something)...
Mysql Usage Is Very High
My mysql usage goes up to 40% of CPU. I think one of my mysql database is causing the issue. I store images in that tables. The select query takes nearly 0.4S to 1.5Sec to fetch a single row. mysql> desc images; +----------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+----------------+ | id | bigint(20) | | PRI | NULL | auto_increment | | slideid | int(11) | YES | | NULL | | | filename | varchar(50) | YES | | NULL | | | fileinfo | varchar(60) | YES | | NULL | | | position | int(11) | YES | | NULL | | | image | mediumblob | YES | | NULL | | +----------+-------------+------+-----+---------+----------------+ mysql> select count(*) from images; +----------+ | count(*) | +----------+ | 5022 | +----------+ e.g query results: 1 row in set (0.31 sec) 1 row in set (1.44 sec)
Mysqld Running 100 Pct Cpu Usage
I am testing mysql 4.1 on a Windows Server 2003 with a website running on Internet Information Services. I installed mysqld as a service. As times goes by, mysqld begins to reach 100 pct cpu usage and doesn't goes below that, Windows usage is slow, folders opens slow, navigating locally turns to be slow, and sometimes it makes the server to freeze or restart. When this begins to happen, I executed the command "Show processlist" and I got the following result. If somebody can point me where is my mistake or where is the problem or any solutions for this, I'm still in a learning process for mysql. Code:
Key_index_size Setting And Usage
I am using MySQL 4.1.12, compiled from source, on a Linux 2.6.11.10 kernel form the kernel archive. My Hardware is a Dual Xeon 2.8Ghz with 8GB of RAM and U320 SCSI disks. The database I am serving is about 6GB total, with the bulk of the data in 2 big tables, about 1.5 GB each. The index files for these two tables are 1.4 GB and 415MB. In my /etc/my.cnf file I have the key_index_size set to 3GB, but the most that will get used is 1.49GB, either after doing an "Optimize tables" or an "INSERT INDEX INTO CACHE" statement. My question is: How does MySQL decide how much of the systems memory to use for the key_index_size and any other of the processes allocatable address space. Also, under linux is the allocatable address space to an individual process 3GB or 4GB?
Allowable MySQL CPU Usage
I am running this query (with subqueries) in MySQL under Windows: SELECT sum(quantity)/(SELECT sum(quantity) from orders), partID from orders group by partID I noticed that it runs very slowly. It appears that MySQL is only using about 2% of CPU capacity, for some reason. The query takes almost 20 minutes to run on my table (whereas the same query takes only 1 minute in MS Access!). Is there a way to allow MySQL to use more of the CPU, so these queries can run more quickly?
Usage Of OPTIMIZE Command
I had a table of more than 800'000 rows where I deleted approx 200'000 rows. The documentation says that I shouldn't normally have to use the OPTIMIZE TABLE command, but performance on this table has not improved. Is it a good idea to use it?
Proper MySQL Usage
I'm looking to use MySQL on my next project, but I don't really know how to set it up so it fits my needs. I am making a Music Script Basically. All I need to store is Artist Name, Artist Videos, and Artist Songs. (just names of the stuff) Artist Videos & Artist Songs are unknown, size wise. Different artists are going to have different numbers of songs and videos.
Usage Of DELETE In A Query!
I know just enough about MySQL to insert, update and if necessary alter tables. But I helped someone that was wanting to delete a rwo of data selected with a form which presented all the row and had a link to take them to another page where it was confirmed by clicking another sumbit button that would remove the row selected from the prior page, then they sent a Private Message stating that the code worked, but then mentioned something about having a foreign key and not being able to delete that field. It is my limited understanding but if I had a table and did DELETE FROM tablename WHERE orderid='$orderid' then this would remove this row whatever the row with an orderis that matched. I built my own table which merely consisted of an autoincrementing PRIMARY KEY of orderid and when I tested the code the row was in fact removed, so what if there were a foreign key? I don't think it would matter, but after the PM I wonder.
Lowering Memory Usage
there's any way I can lower MySQL's = memory useage? It often uses more than 50000kb which I consider to much.. I'm guessing I should play with my.cnf or whatever it's called (located at = C:/ and windows calls it cardnumber or something)
Measuring Database Usage
I'm trying to write a backup script, but want to be 'resource smart' about it. I'd like to backup my database every hour or 2, but want to look at the current draw on the DB prior to running the backup. If the draw is within pre specified limits, do the backup, otherwise, sleep for a min then try again. This may be more of a job for a shell script, but I figured I'd give the mysql forum a try.
Showing Disk Usage
How can I see how much disk space is being occupied by an InnoDB table? Looking into /var/lib/mysql doesn't seem to work anymore for InnoDB tables. Please tell also if there is a way to see how much space is occupied by a particular row or column of a table.
4.0.14 Runs CPU Usage Up And Eventually Stop
I am running 4.0.14 on a FreeBSD 4.8-STABLE machine (upgraded to CVS from last week) and I am having a problem. We run a fairly large website using PHP so there is always many connections to the database. On 4.0.12 the cpu usage never shot to over 20% and ran extremely fast. After upgrading to 4.0.14, the cpu goes anywhere between 20-60% and in many situations will not accept any database connections. After browsing the website for a few minutes, I will type mysql on the command line and it will give an error of too many connections. Does anyone know what may be causing this high load from the upgrade? Again the previous versions did not do this and ran very well. I could use 4.0.12 but I wanted to report this in case it continues in future versions.
Single Computer (stand-alone) Usage?
I'm hoping to install MySQL on my home desktop computer (where I'm running Ubuntu Linux) and come close to simulating conditions at work (where we use MS Windows XP/Server/SQL Server). I'm also interested in doing this for an online "SQL Intro" course I'm going to be taking in October... Is it possible to install MySQL and work from my desktop PC as both the server and the client? If so, can somebody point me towards some documentation?
Configuration And Usage Of The Relation Feature
im just creating a new database for a browser roleplaying game. Maybe you can imagine how complex this can be sometimes. And while i was working on it i remembered a feature of the MS access database. At access you could create relations for various tables, so if u change a field in one table, it is changed for all fields related/linked to it. Is there a similar feature in mysql, and if yes, is it the "linked_tables" feature?
4.0.14 Runs CPU Usage Up And Eventually Stop
I am running 4.0.14 on a FreeBSD 4.8-STABLE machine (upgraded to CVS from last week) and I am having a problem. We run a fairly large website using PHP so there is always many connections to the database. On 4.0.12 the cpu usage never shot to over 20% and ran extremely fast. After upgrading to 4.0.14, the cpu goes anywhere between 20-60% and in many situations will not accept any database connections. After browsing the website for a few minutes, I will type mysql on the command line and it will give an error of too many connections. Does anyone know what may be causing this high load from the upgrade? Again the previous versions did not do this and ran very well. I could use 4.0.12 but I wanted to report this in case it continues in future versions.
Speed / Processor Usage Of Mysql
I am running MySQL 4.0.16-nt with the myODBC connector (3.51) on an IIS5 machine. If I am inserting a record it goes like the blink of an eye - 759 inserts boom done extremely fast. Then I run an ASP script to update the 759 records just inserted like this. SQLstmt = "UPDATE tblServer3 " SQLstmt = SQLstmt & "SET fldLand=" & strLand SQLStmt = SQLStmt & " WHERE fldDate='" & strNextContact & "' AND fldName='" & strName & "';" Set RS = Conn.Execute(SQLstmt) That specifies to filter based on name & date (I cannot filter on ID) Table has a total of 29,761 records The total table size is 2.2mb It does indeed to do the update, but it is extremely slow, 759 records updated in about 5 minutes, 40 seconds. That is about 2.2 records a second. Processor utilization shoots up to about 50% usage per processor (2 processors) Code:
Detecting High CPU Usage Queries
I know I can log slow queries, but what about ones that require a huge amount of CPU power to process? I have a lot of those lately it seems and I am trying to track down the culprits.
MYSQL_FIELD + Mysql_fetch_field, Memory Usage
I would like to understand when memory allocated by mysql for field is released. In my source code, you can see : MYSQL_FIELD *field; .. .. field = mysql_fetch_field(res); Is it normal to never free the FIELD variable ? Is there a function like mysql_free_result() for fileds?
Usage Of CONCAT Operator When Creating A View ...
I am trying to create a view and my syntax is as follows : CREATE OR REPLACE VIEW UDT_GRP_LDR_ACTIVE_V ( PRIKEY , Leader , Group_Name , Group_Description , Meeting_Frequency , Meeting_Time , Meeting_Day , Sector , Focus , AUTO_IMAGE , AUTO_SECURITY_AUTH ) AS SELECT A.PRIKEY , CONCAT (P.PER_FNAME, ' ', P.PER_LNAME) as Leader , G.GRP_NAME , G.GRP_DESC , G.MTG_FREQUENCY , G.MTG_TIME , G.MTG_DAY , G.SECTOR , G.FOCUS , P.AUTO_IMAGE , A.AUTO_SECURITY_AUTH FROM UDT_PER_GRP_ROLE A LEFT OUTER JOIN UDT_PERSON P ON A.PER_ID = P.PRIKEY LEFT OUTER JOIN UDT_CELL_GROUP_ACTIVE_V G ON A.GRP_ID = G.PRIKEY WHERE A.STS_ID = 1 AND A.ROLE_ID = 4; When I run this statement, I get the following error (in PHPMyAdmin) : "#1305 - FUNCTION hart7511_sope1.CONCAT does not exist". At first I thought it was a permissions issue on my account and contacted the SysAdmin at my web hosting company. I'm still waiting for a response from them, but the strange thing is that when I just run the SELECT statement on its own (without the CREATE OR REPLACE VIEW part), it runs fine ... so despite the wording of the error message, the problem doesn't really seem to be with "CONCAT" ... or am I missing something ? BTW I have created other views without using CONCAT and had no issues.
Mysql Setup/usage/understanding Docs
Someone have a link to some howtos or docs that easily walks you through basic setup and usage of mysql? I do not need to know the ins and outs of mysql, just enough to get it up and running smoothing/securely and basic navigation info.
MYSQL - CPU Usage High On Windows 2003
I've been working on this for about a week now... When there is a lot of activity/traffic on the site mysql procees seems to "lock up" with high CPU usage and everything in windows seems to freeze. I am running mysql 4 on IIS 6 using an odbc connection via ASP. I've tried everything, indexing, optimizing, pooling, disabled the virus software running in the background, I even tried using my.cmf, etc, nothing seems to help. Is there anyone who can help or anyone else experiencing this same problem? Could it be a hardware issue?
Disk Usage Increases After Dropping A Large Index?
I have a linux server which is hosting several very large (~20GB) databases. In order to save some disk space I dropped an index on one of the larger (InnoDB) tables because it is no longer needed. It took about 30 minutes for MySQL to drop the index, during which time I saw the free disk space decrease. I didn't think anything of it while the drop operation was running because I figured it was some kind of temp file being used by the drop (even though the temp directory for mysql is supposed to be on another partition). To my surprise, after the index was dropped, not only did I not have more free space as I expected, but in fact I had about 2 GB less than I did before I dropped the index. Huh? So now I'm down 1 index and 2 GB of space. How does dropping a db object actually increases the amount of disk used by mysql? Is there anyway I can reclaim this space? MySQL version is 4.0.15
#1136 - Column Count Doesn't Match Value Count At Row 1
I'm getting the above error with the following SQL Statement. I cannot seem to find the error in the code. The select statement does pull multiple rows. I'm using my SQL version: 4.1.19 Any clue on why this isn't working? INSERT INTO `Grants` ( `Project_Code` , `Grant_Code` , `Fiscal_Year` , `Capital` ) VALUES ( ( SELECT Project_Code, Grant_Code, FY, SUM( Capital ) FROM Grants_Temp WHERE Project_Code = 'OSUT' AND FY = '2006' AND Claim_Month = '072006' GROUP BY Grant_Code ORDER BY Grant_Code ) )
Mysqld Shows High Cpu Usage Over Extended Time, Restart = Normal
Occasionally in checking one of the servers, I noticed that mysql shows 85% + of cpu usage essentially leaving the server at 0% idle. After monitoring it for a few hours, the status did not change. After a stop and start of mysql, things progessed normally. Checking back a few days later I noticed it was once again sitting up there at 95% (or thereabouts) and doing nothing of value from what i could tell. Have restarted MySQL during peak usage times for that server and its database, and it has showed normal loads and CPU usage (approx 20% CPU with .1 to .3 load). Is there a known issue (running on FreeBSD 4.8, MySQL 3.23.55 MyISAM)? Is there something I should check when next I notice the high CPU usage?
Column Count Doesn't Match Value Count At Row 1
I am getting the following error when I run my query. Column count doesn't match value count at row 1 I have looked up this error and have checked and I appear to have the right number and names in my query. In the DB table I have 34 columns, and that is what I have in the query. The last 4 in the query are for the names of the images being uploaded, but am not sure how this all works, so I don't know if I need them, but have them there until I know for sure. Comment, Purchase and Remarks are not used in this form, but I have added them so everything is being shown in the query. Code:
Count(*) As Count And TotalCount Of Count
data in myTable1 (n) country_id (1) 3 (2) 1 (41) 1 (5) 2 (6) 3 (7) 4 data in myTable4 (time) param (10 : 10) c=4 (10 : 12) c=2 (10 : 30) n=41&k=5 (10 : 35) c=1 (10 : 37) n=5 (10 : 50) c=2 (10 : 54) c=2 (10 : 55) n=1&cate=6 (11 : 12) c=2 (11 : 15) n=7 (11 : 20) c=1 I have data in myTables like the above. I have the following code. code (select left(time,2) as hour, count(*) as count from myTable4 where left(param,1)='c' and substring(param,3,1)=2 group by left(time,2) ) UNION all (select left(time,2) as hour, count(*) as count from myTable4,myTable1 where left(param,1)='n' and substring(substring_index(param, '&', 1) ,3)=myTable1.n and myTable1.country_id=2 group by left(time,2) ) order by hour And the code above produces the following result. result (day) count (10) 3 (10) 1 (11) 1 The following would-be code doesn't work correctly, but it will show what I want. would-be code (select left(time,2) as hour, count(*) as count, sum(count) as totalCount from myTable4 where left(param,1)='c' and substring(param,3,1)=2 group by left(time,2) ) UNION all (select left(time,2) as hour, count(*) as count, sum(count) as totalCount from myTable4,myTable1 where left(param,1)='n' and substring(substring_index(param, '&', 1) ,3)=myTable1.n and myTable1.country_id=2 group by left(time,2) ) order by hour And the following is my target result. target result (day) count totalCount (10) 3 5 (10) 1 5 (11) 1 5
How To Fix "Column Count Doesn't Match Value Count At Row 1" ?
I've been trying to install a portal to my installation of Invision Power Board, and I keep coming up with this problem. I post here for two reasons: firstly is that no one is responding over at the portal creator's thread and I need help, second is that this error looks like a mySQL error that could be solved without the need of the creator if possible. Here is the error returned: mySQL query error: INSERT INTO `ibf_portal_box` VALUES (1, 'lang.last_topics', '<box><menu>10,20,30,50</menu> <topics_show>10</topics_show> <order>last_post</order> <exforums></exforums> </box>', 0, 'middle', '*', 0, 4, 'last_topics', '1') mySQL error: Column count doesn't match value count at row 1 mySQL error code: Date: Tuesday 21st of December 2004 08:43:10 PM I am very new to mySQL and don't really understand it. What is wrong with the above that it is trying to insert, and how is it fixed?
Count(*) In A Select Returns "1". It Should Behave Like Select Count(*)
i'm trying to make a query work properly but I got lost: SELECT *,count(*) FROM cancons c, musics m, discos d, r_discos_cancons rdc WHERE c.c_id_music = m.m_id AND rdc.rdc_id_disc = d.d_id AND d.d_id_music = m.m_id AND m.m_id = 24 GROUP BY c_id note: cancons (ca) = songs (en) discos (ca) = cd's (en) music (ca) = musician (en) don't worry for the WHERE part. i need it because of the foreign keys. this query returns a table with the title of the song and some more data. on the right side, I get another column called "count(c_id)" with the number "1" in it for each row. That's supposed to be due to the "group by" clause, I think. I'd like to get the table with the songs, as usual, and, with the same query, I'd like to get the total number of rows selected.
|