w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Unable to login to MYSQL getting error ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
It seems like a permission issue, try disabling selinuza by using setenforce 0, then restart the mysql service, also check if mysql has the right permissions on the mounted device (assuming you mounted as root or a sudo user that mysql cannot access)

Categories : Mysql

MySQL Default value error in Windows and not in Linux when the value is not given for NOT- NULL field?
As mentioned in the first comment, it seems a configuration problem. Checks particularly the variable sql_mode SELECT @@sql_mode; and values TRADITIONAL | STRICT_ALL_TABLES | STRICT_TRANS_TABLES.

Categories : Mysql

Error when trying to insert inside a DateTime field in database mysql
It looks as though your date value is unquoted and it (the sql) looks thus to the database ..., 09:23:12) which won't work. Try a) inspecting the actual value before using it, making sure it is quoted (if you have to use a string) and/or b) use one of the mysql built-in conversion functions so that you are passing a date object and not some kind of string. e.g STR_TO_DATE documented here

Categories : PHP

MySQL 5.6 Error 1054: Unknown column in 'field list' on INSERT
I Think your trigger creates problem.So try this one.. CREATE TRIGGER `update_mailbox` AFTER INSERT ON COMIC_ISSUE FOR EACH ROW begin INSERT INTO MAILBOX_has_COMIC_ISSUE VALUES ((SELECT MAILBOX_mailboxID FROM MAILBOX_has_COMIC_TITLE WHERE MAILBOX_has_COMIC_TITLE.COMIC_TITLE_name = new.COMIC_TITLE_name), (SELECT MAILBOX_CUSTOMER_customerID FROM MAILBOX_has_COMIC_TITLE WHERE MAILBOX_has_COMIC_TITLE.COMIC_TITLE_name = new.COMIC_TITLE_name), new.COMIC_TITLE_name, new.volumeNum,new.coverDate); end$$ Two keywords are unique to SQL statements while defining triggers i.e; OLD and NEW. These keywords allow you to refer the data before and after the event triggers. Check this once... http://www.w3resource.com/mysql/mysql-triggers.php

Categories : Mysql

MySQL perfomance: letting a UNIQUE field generate an error or manually checking it
If you check then update, you have to query the database twice. And its turn it will check the table index twice. You have both network overhead and database processing overhead. My point of view is you have to be optimistic: update and handle gracefully the potential failure if there is some duplicate values. The two-steps approach has one other drawback: don't forget there will be concurrent access to your database. Depending on you database setup (isolation level, database engine), there is a potential that DB was modified by an other connection between the SELECT and your UPDATE.

Categories : Mysql

mysql - fill / update field by other fields based on another field condition being true
Unless I'm misunderstanding you, you want to use a WHERE clause: UPDATE table1 SET field4 = CONCAT(field1,field2) WHERE field3 = "XYZ" Here is some information on it.

Categories : Mysql

PHP and Mysql, about delete record if field has 2 occurrences of $, dollar sign in price field
UPDATE table SET produce_price=0 WHERE produce_price LIKE '%$$%' Just let the database do the work. Edited to allow pricing as previously shown (btw really bad to store the price symbol in a column, the column should be decimal(10,2) format and just store the price value ie xxx.xx in it your currency symbol should be in application. UPDATE table SET produce_price='$0.00' WHERE produce_price LIKE '%$%$%' OR produce_price LIKE '%$$%'

Categories : PHP

MySql select single instance of a 3 field combo based on lowest value of 4th field
A simple LEFT JOIN can check for people with the same department/position/grade and find the one with the lowest salary. The DISTINCT is added to avoid duplicates with the same salary; SELECT DISTINCT t1.* FROM Table1 t1 LEFT JOIN Table1 t2 ON t1.position = t2.position AND t1.grade = t2.grade AND t1.department = t2.department AND t1.salary > t2.salary WHERE t2.salary IS NULL; An SQLfiddle to test with.

Categories : Mysql

How to combine a field from multiple tables into a single field in a MySQL View?
You need UNION: create view codes as select code from table_a union select code from table_b union select code from table_n Please note by default, UNION is UNION DISTINCT: it removes duplicates. If you want to keep them, use UNION ALL.

Categories : Mysql

MySQL order query by priority field and status field
You can use FIND_IN_SET order by find_in_set(`priority`, 'open,close'), find_in_set(`status`, 'high,medium,low')

Categories : Mysql

MySQL: how to sort rows by a field and assign another field a counter?
update your_table t1 inner join ( select id, @rank := @rank + 1 as r from your_table, (select @rank := 0) r order by y ) t2 on t2.y = t.y set z = r SQLFiddle demo

Categories : Mysql

Why doesn't my content field match my MAX(id) field in MySQL?
Well, you could probably solve it without a subselect, but doing one is fairly straight forward. Something like this should work, just make the subselect return the id's of the interesting rows in messages, and get the data for only them. SELECT m.id as id, m.sender_id, m.receiver_id, m.date as date, m.content, l.username, p.gender FROM messages m LEFT JOIN login_users l on l.user_id = m.sender_id LEFT JOIN profiles p ON p.user_id = l.user_id WHERE m.id IN ( SELECT max(id) FROM messages WHERE receiver_id=3 GROUP BY sender_id ) ORDER BY date DESC LIMIT 0, 7 The reason that your original query does not match up fields is that GROUP BY really requires aggregate functions (like MAX/MIN/SUM/...) applied to every field you select that's not grouped by. The reason the query

Categories : Mysql

MySQL create Datetime field from Timestamp field
I knew I was nearly there!! It was not UNIX_TIMESTAMP but FROM_UNIXTIME I was after. UPDATE news SET created_date = FROM_UNIXTIME(date) Thanks for the help. Steve

Categories : Mysql

MYSQL hide field data if value in another field is set
Logic of this sort probably best belongs in the presentation, rather than database, layer of your application. However, it is nevertheless possible using either MySQL's IF() function or its CASE expression—for example: SELECT art, type, IF(type='b',NULL,price) price FROM x; See it on sqlfiddle.

Categories : Mysql

add datetime field value to integer field value in mysql
I think what you need is the MySQL's date_add() function - http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-add. For example, DATE_ADD('2013-06-22 09:46:00', INTERVAL 1 DAY), where you may replace the date-time and day interval with the corresponding column names. UPDATE Let us assume, the date-time field is called FIELDA and the integer field is called FIELDB representing days, then the function might be called as: DATE_ADD(FIELDA, INTERVAL FIELDB DAY); If however the integer field represent hours, you may call it as: DATE_ADD(FIELDA, INTERVAL FIELDB HOUR); Hope above helps!

Categories : PHP

add some char to field until x field length MYSQL
Use LPAD() select LPAD(field1, 3, '0') from table1 SQLFiddle demo

Categories : Mysql

Copy links from mysql field to another field
Mysql has lots of string manipulation function See here You can use these functions in a query for example: ( very simple example ) UPDATE table SET new_field = SUBSTRING(old_field, INSTR(old_field, '<a'), INSTR(old_field, '</a>') ) WHERE id = 10; So with the use of SUBSTRING and INSTR and maybe a few others you can develop a query to do the job.

Categories : Mysql

Check if mysql field contains a certain number in mysql query
Perhaps: select * from TableName where ids = '5' -- only 5 or ids like '5,%' -- begins with 5 or ids like '%,5' -- ends with 5 or ids like '%,5,%' -- 5 in the middle somewhere It probably won't be very fast on large amounts of data. I'd suggest normalizing these multi-selection values into a new table, where each selection is a single row with a link to TableName.

Categories : PHP

django - forms- Field error - Unknown field(s) (a, l, _) specified for
I guess you are using Django 1.5 or previous version. __all__ only exists in Django 1.6+: Before version 1.6, the 'all' shortcut did not exist, but omitting the fields attribute had the same effect. Omitting both fields and exclude is now deprecated, but will continue to work as before until version 1.8 So change your code to: from django.forms import ModelForm from ver11.models import studentdetails class studentform(ModelForm): class Meta: model = studentdetails # omit the fields totally Also please read PEP8 for name convention and style.

Categories : Django

MYSQL: select multiple if(field='x' max(time) / if(field='y' min(time)) values in a single statement
You can't do it this way. The reason you're getting a null for the "other" column is because that agent_state doesn't exist when you group by agent and date. If you add the agent_state to the group-by you'll get 3 rows per agent/date. This isn't quite what you want. You need a subquery or a couple self-joins. Try something like this: SELECT agent, date, MIN(dur) AS total_duration, TIMEDIFF(MIN(maxt), MIN(mint)) AS time_difference_between_login_and_out, MIN(maxt) AS logout_time, MIN(mint) AS login_time FROM (SELECT agent, date, IF(agent_state = 'Ready', SUM(time), NULL) AS dur, IF(agent_state = 'Logged-in', MIN(time), NULL) AS mint,

Categories : Mysql

MySql: How to check field has data in MySql?
try this query: SELECT DISTINCT CAL.CarListingId, CAL.ListingNumber, CAL.Caption, CAL.Year, CAL.Km, CAL.Color, CAL.Price, CONCAT((SELECT Name FROM City WHERE CityId IN (SELECT CityId FROM County WHERE CountyId = CAL.CountyId)),'/', (SELECT Name FROM County WHERE CountyId = CAL.CountyId)) AS Region, CAL.Creation, ( case when CI.ImageUrl IS NULL then 'asdf' else CI.ImageUrl end) FROM carlisting AS CAL LEFT JOIN CarImage AS CI ON CI.CarListingId = CAL.CarListingId INNER JOIN User AS U ON U.UserId = CAL.CreatedBy INNER JOIN carlistingcategory AS CLC ON CLC.CarListingId = CAL.CarListingId ORDER BY CAL.Creation;

Categories : Mysql

Use order by field for certain field, but keep order in date field - MySQL PHP
You can generally sort the data according to date after sorting by request_status SELECT * FROM table ORDER BY FIELD(request_status, 'wait', '2edit', 'ok', 'no'), `date`

Categories : PHP

Error that field is required when there is no field empty
Setting blank=True on connection will remove the form's error. If you want the file to be nullable in the DB then you can set null=True or just establish a default value. In order to remove the form error you just need to do this: connections = models.ManyToManyField('self', related_name='connections', blank=True) Hope this helps!

Categories : Python

DBD-mysql installed ,but still error "install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC"
Perhaps the DBD::mysql perl module hasn't been fully installed ...so install it. cpan DBD::mysql Or since you don't have internet access, perl Makefile.PL make make test make install You'll need MySQL's development header files installed first, as per INSTALL

Categories : Perl

How to create a Django custom Field to store MYSQL DATETIME(6) and enable fractional seconds (milliseconds and or microseconds) in Django/MySQL?
I've tried this succesfully, but my approach is quite different: I split the info in a DateTimeField (UTC) and a IntegerField (microseconds = uS): from datetime import datetime, timedelta import pytz class MyModel (models.Model): # My model stuff and other fields here _UTC = models.DateTimeField () _uS = models.IntegerField() And then I set a property in the class to return UTC with microseconds and zone info aware (because my database doesn't support zoneinfo) @property def UTC (self): utc = self._UTC us = self._uS # add microseconds utc += timedelta(microseconds=us) return utc.replace(tzinfo=pytz.utc) @UTC.setter def UTC (self,utc): self._UTC = utc-timedelta(microseconds=utc.microsecond

Categories : Django

MySQL Cluster ERROR 1296 (HY000): Got error 157 'Unknown error code' from NDBCLUSTER
Error 157 is actually 'could not connect to storage engine' and the fact that MySQL fails to report that error correctly is a bug: http://bugs.mysql.com/bug.php?id=44817 The case described in that bug mentions that you get the error when you try to query a table in NDB when the cluster is still down. So I'm just guessing, but I would conclude that your cluster is not started. Either you missed starting one of the nodes, or else something went wrong starting one of the nodes.

Categories : Mysql

Django form field error: one character per error?
Seems to me that the problem is the error loop is iterating through a string, which makes sense because you define it as a string. form.errors['password'] = 'Incorrect password, please try again.' Try it wrapping it in a list: form.errors['password'] = ['Incorrect password, please try again.'] This may also happen with email. Hope this helps!

Categories : Django

MySql Count on each field
Haven't tested but you can try this. Tell me the result so we can update if necessary. select month, sum(QuestionA), sum(QuestionB), sum(QuestionC), sum(QuestionD) from table_name where month='Jan'

Categories : Mysql

How to select an "AS field" in MySql?
You can't use an aliased column name in the select or where clause. You could use it later in the group by, order by, having clause. See the MySQL doc for that.

Categories : Mysql

MySQL ENCRYPT field to MD5
Firstly MD5 is a hashing algorithm not a encryption algorithm. The main reason for this is that it is virtually impossible to calculate the original password from the hash value generated by MD5. MD5 creates a hash value and it basically a trap door function in other words it is a one way function. Encryption will allow you to encrypt and decrypt IF you knew the key. Big difference. Hope you understand that. Now for your problem. Unless you have the original password before it was encrypted there is no reasonable way besides brute force to create the MD5 equivalent of the password. The encrypted passwords hash and the unecrypted/plain text password hash will be two different think. If you can decrypt all the passwords you currently have to their plain text form you can perform the MD5

Categories : Mysql

Mysql table field name
Check this out. Great stuff. Good luck! SELECT d1.* FROM database1.school d1 LEFT JOIN database2.school d2 ON d1.name=d2.name WHERE d2.name IS NOT NULL;

Categories : PHP

Mysql group by in a CSV field
If you can't change your table structure, but you can create a table that lists all the colors, you could use this query: SELECT Colors.Color, Count(*) FROM Products INNER JOIN Colors ON FIND_IN_SET(Colors.Color, REPLACE(Products.Color, ' ', ''))>0 GROUP BY Colors.Color See it working here. Please notice that it can't be optimized because it can't make use on an index.

Categories : Mysql

PHP - insert same field into mysql
You need to POST the per-product details as an array. In the markup you would use <input name="id_product[]"..../> This will then be received in PHP as an array (echo gettype($_POST['id_product']) will output array). Then you can loop through with foreach ($_POST['id_product'] as $id) or something else, and call your INSERT INTO sale_detail... query multiple times (once per loop iteration). Note that you only want to put [] in the name attribute of the values that actually are per-item. For example the no_invoice field is a single value, not an array, so you would just use name="no_invoice" and not name="no_invoice[]".

Categories : PHP

Trying to connect to mysql server for the first time and get an error messange: "mysql: command not found"
Your terminal application doesn't know where to locate the mysql program. For example, if you installed xampp in C:/xampp, you open a command prompt, cd to C:/xampp/mysql/bin and then run your command, which should work now. Edit: Just remembered you mentioned OSX, regardless, use the same principle. In your terminal, cd to the XAMPP install subfolder which contains the mysql executable app

Categories : PHP

MySQL Trigger Error #2013 - Lost connection to MySQL server during query
Change SET cmd=CONCAT('/home/lab/Dropbox/simulator/version_unified/./simulator'); to SET cmd=CONCAT('/home/lab/Dropbox/simulator/version_unified/simulator'); ./ is used when the file is in the current working directory.

Categories : C++

While using Mysql cast function getting the Check Mysql version or the right syntax error
SELECT EM.rec_id AS rec_id,EM.employee_code, EM.employee_name, EM.designation, EM.weekly_off_day, EM.gender, EM.payment_type, SM.shift_name, PM.plant_name, EM.status AS status,EM.settlement_no, SCM.section_name FROM employee_master AS EM INNER JOIN shift_master AS SM ON EM.shift_rec_id = SM.rec_id INNER JOIN section_master AS SCM ON EM.section_rec_id = SCM.rec_id INNER JOIN plant_master AS PM ON EM.plant_rec_id = PM.rec_id ORDER BY CAST(EM.employee_code As UNSIGNED ) See this SO thread

Categories : Mysql

I am getting mysql error check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 4
Try putting quotes around your question mark if it's the value in the database you're filtering by: $query_str = "SELECT cm.user_id, chat_message_content, u.firstname FROM chat_message cm JOIN user u ON cm.user_id = u.user_id WHERE cm.chat_id= '?'";

Categories : Mysql

Inspite of setting (null=True, blank=True) for ModelForm field, I get validation error on leaving the field blank
Set the field to required=False class MyForm(ModelForm): filing_date = DateField(input_formats=['%d-%m-%Y'], widget=DateInput(format=('%d-%m-%Y'), attrs={'class':'input-block-level datePickBootstrap', 'placeholder':'Filing date'}), required=False) class Meta: model = try

Categories : Django

how to make a field of a query in mysql to be an INT
If you want to round the result: SELECT ROUND((tblcopago.bonos + tblcopago.copago) * tblagenda.ValorServicio / grupo.Total) as Copago If you want to floor it (truncate to the lower int): SELECT FLOOR((tblcopago.bonos + tblcopago.copago) * tblagenda.ValorServicio / grupo.Total) as Copago ... And if you want the upper value (truncate + 1): SELECT CEIL((tblcopago.bonos + tblcopago.copago) * tblagenda.ValorServicio / grupo.Total) as Copago See MYSQL Mathematical Functions

Categories : Mysql

MYSQL GROUP By + ORDER BY FIELD()
You should SELECT only fields you have in GROUP BY or aggregated result Actually in you case you don't need GROUP BY because you don't have any aggregated functions(sum, count,avg etc)

Categories : Mysql



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.