Questions tagged [mysql++]

117822 questions
2

votes
3

answer
40

Views

Convert A Date in MySQL

I have a value set in my database as 04/01/2019. I need to construct a script in either php or MySQL that goes through each line in the table that has this value, and convert the string to 2019-04-01. Dates will vary, so 02/01/2019 has to be converted to 2019-02-01, etc. I have been reading for hou...
BCode18
-4

votes
0

answer
21

Views

Learning process - website tracking hours for multiple users [on hold]

Im kinda new to it all - css, html, sql and php. But Im learning, and I`m dedicated for now. I have put up a website for testing and learning, with username/password log in, and where username is assigned for session when logged in. When you log in to mainpage, you can put in the date and hours work...
Per Askeladden
1

votes
1

answer
19

Views

How to find the columns that need to be indexed?

I'm starting to learn SQL and relational databases. Below is the table that I have, and it has around 10 million records. My composite key is (reltype, from_product_id, to_product_id). What strategy should I follow while selecting the columns that needs to be indexed? Also, I have documented the ope...
Tech Guy
-1

votes
1

answer
18

Views

SQL Query by using left or right outer join

I've table name as "Employee" with respective columns(id,employee_id and status). If status is in "pending" and take pending status of "employee_id" and lookup into other records of employee_id column. So employee_id is exist then I've to take id value and store into result_id. id employee_id...
user10251274
-2

votes
1

answer
15

Views

Strange MYSQL behavior on TABLE CREATE

The command: CREATE TABLE IRdata (ego int, altr VARCHAR(20), species VARCHAR(20), sex CHAR(1), birth DATE, death DATE); works, but CREATE TABLE IRdata (ego int, alter VARCHAR(20), species VARCHAR(20), sex CHAR(1), birth DATE, death DATE); does not. The only difference is the "e" in "alter" for the...
R-Enthusiast
0

votes
1

answer
5

Views

phpMyAdmin MySQL Database - Reset auto increment number on existing table and re-apply from beginning

I have a table with existing data that has a unique and auto increment key column named "_id" and several other columns and because this was a test database, I deleted some random rows and would like to reset my _id column to 1 and auto fill the existing _id rows automatically by adding +1 (same as...
user3560827
0

votes
0

answer
5

Views

MySql Count Rework and SUM Rework by Phase

i need some help regarding the following query in MYSQL. I have following SQL Table: LINK I need to calculation the following: 1. Query: Count of Rework by phase For example (based on orderid 749, see the Link) The order was already three times in phase 01. The first occasion of phase 01 is to be ca...
Richi4100
0

votes
0

answer
5

Views

How to display an image from mysql using Express

I have a sql table 'animals' where there are blobs images. I found out how to upload images but not how to display them. I would like to display the image which is called 'Dog' in my table. Here is my code, where I print the result of my blob img. let sql = 'SELECT * FROM animals WHERE file_name=\'D...
Julien
1

votes
1

answer
158

Views

Select date from another table

I really need your help. Please help me out to get this to work. I have these two tables, the relation between them is the user_id. I accomplished to select who I follow and to display their images into my wall. However, I have this strange issue: the photos are sorted by DESC as i want, but they ar...
user2660611
1

votes
2

answer
220

Views

php calling function dynamically with @ symbol

I want to call the mysql_connect function dynamically with the @ symbol, depending on if the user is an admin or not (to supress error messages): //User is an admin: mysql_connect(...) //User is not an admin: @mysql_connect(...) I have tried this: //MODE_ADMIN is true or false private static func...
Ilyssis
1

votes
1

answer
240

Views

Java getting the auto-increment number of the current inserted row, to use it for another query?

public static void updateHistory(Client winner) { try { if (winner != null) { getDatabase().newQuery("INSERT INTO tournaments (`players`, `winner`, `winnerKills`, `map`, `prize`) VALUES ('" + tournyPlayers.size() +"', '" + winner.playerName + "', '" + winner.killCount + "', 'Wilderness', '" + winner...
Jony Kale
1

votes
2

answer
2.5k

Views

can't connect to the mysql server on '127.0.0.1'

I am trying to connect to the mysql in MAMP using navicat. I read that in advance settings i need to set path of mysql.sock. But i couldn't locate this file in Application/MAMP/tmp/mysql. Questions : Do i have to set this path ? Any reason why this is not located in this folder ? If i try to conn...
keen
1

votes
1

answer
46

Views

mysql query joining three queries into sigle query

Please help on this query, here is sql fiddler : http://sqlfiddle.com/#!2/8acc1/1 SELECT DISTINCT c.id, v.sel_category,c.curr_tittle , c.curr_desc, v.videos_desc FROM wp_curriculum c, wp_career_vidoes v WHERE c.id IN (SELECT DISTINCT curr_id FROM wp_curriculum_category WHERE curr_category IN (...
Vasanth
1

votes
4

answer
673

Views

Mysql - order by certain strings

I have a players table. Each player has a position which is either goalkeeper, defender, midfielder or forward. I want to return all players, with forwards first, then midfielders, then defenders, then goalkeepers. Obviously, if I do: SELECT * FROM 'Player' ORDER BY position the defenders will be...
user1716672
1

votes
1

answer
145

Views

PDO prepared statement security

This is my first participation is this great website, so I hope to get the first great answer to my question. I'm using the following code to insert data into MySQL database: if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) { $q = $conn->prepare("INSERT INTO client (name, addre...
Anibel
1

votes
1

answer
2k

Views

django with mysql what does 'maximum number of connections'?

I am writting simple application which django that can be used internally inside my office. probably 1000 people i say. I dont have any session handling, user handling. It is just a store/view process in the django. What i understood? 1) django closes reopens the database connection on each request...
Whoami
1

votes
1

answer
2k

Views

creating a connection in eclipse - ClassNotFoundException: com.mysql.jdbc.Driver

I am not doing anything in code - I just created an eclipse connection and can't seem to be able to ping it. The connection properties : The jar is where I say it is ($GLASSFISH_HOME\domains\domain1\lib\ext) but I am getting : java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at java.net.URLCl...
Mr_and_Mrs_D
1

votes
2

answer
584

Views

Using scope in Rails model for gathering “private” posts

I have a table of user Posts, some of which are private, denoted by a boolean column (privacy) in the table (true being private). In my livefeed view (posts/index.html.erb), I want to show only the non-private posts for ALL users. Can I do this via my scope? Note: In my usersfeed view I am showing p...
Jet59black
1

votes
2

answer
1.5k

Views

MYSQL select unique id's where column value is not null in one or more records

Background I have a table that contains customer purchase records, the table has a column named coupon_id, this column is null if a customer didn't use a coupon during a purchase and contained the coupon id if they did. The table can contain several purchases for a single customer, a customer may ha...
Levi Putna
1

votes
2

answer
2.4k

Views

Golang MySQL Database Not Selected

I'm using github.com/go-sql-driver/mysql package to connect to MySQL. It works well except when I select a database (USE), I can't run queries against it. package main import ( "database/sql" "fmt" "log" ) import _ "github.com/go-sql-driver/mysql" func main() { dsn := "root:@/" db, err := sql.Open("...
Mark
-3

votes
0

answer
38

Views

SQL Error when updating a table in my PHP form [on hold]

So I'm trying to get this request to work, however despite the "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 ''" I can't seem to find an error in the syntax. Here's the code : $request["update"] = "UPDATE ap_stu...
Outjacked
1

votes
4

answer
30

Views

Most frequent value with group by two columns mysql

I have a table (test) with two columns (name varchar(5), cnt int) Table Name: test +--------+-------------+ | column | type | +--------+-------------+ | name | varchar (5) | | cnt | int | +--------+-------------+ and have values +------+-----+ | name | cnt | +------+-----+ | A...
Atiq
-3

votes
0

answer
34

Views

SQL Error when updating a table in my PHP form

So I'm trying to get this request to work, however despite the "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 ''" I can't seem to find an error in the syntax. Here's the code : $request["update"] = "UPDATE ap_stu...
Outjacked
1

votes
4

answer
110

Views

MYSQL: Find all posts between certain users

I have two tables: table message (holds the creator of a message and the message) id - creatorId - msg and a table message_viewers (tells who can read the message msgId) msgId - userId If I create a message as user 1 and send it to user 2 and user 3, the tables will look like this: tbl_message:...
user3010549
1

votes
1

answer
2.1k

Views

Using setConnection on Laravel 4 Models

I am trying to set the connection in use by a model in Laravel 4 before getting instances of the model from a secondary database. I have correctly filled in the information for the secondary connection in Config/database.php, but for some reason Laravel is reverting back to the default connection wh...
Zac Crites
1

votes
2

answer
1.3k

Views

Python: Proper way to store list of strings in sqlite3 or mysql

I'm trying to store a list of string values into a sql database. list = ['please','help','me'] I've tried converting to unicode and using the array.array('u',list) unicode_list = unicode(list) array.array('u', list) This is not producing the results that I want. I'm not too concerned with being abl...
django-d
1

votes
1

answer
1k

Views

Connection to MySQL inside fooreach loop slow down my php page

I have appointment script in php + mysql. in the script I have 6 column and every column have 64 row that is equal to 384 field. For every field I have one mysql_query connection, that mades 384 connections to MySQL. is there any way to make this script more effective and faster??? Also i want to ad...
mandza
1

votes
1

answer
67

Views

PRIMARY and FOREIGN key in one field

I have 3 tables: users, pages and users_pages Users Table +----+------+----- | id | name | ... +----+------+----- Pages Table +----+------+----- | id | name | ... +----+------+----- users_pages table, which says, which user is admin of which page. +---------+---------+ | user_id | page_id | +-------...
Pars
1

votes
3

answer
121

Views

How to increase the MySQL variable count

Friends, in my project I have a variable named bill_number; every time the PRINT bill button is clicked I want to increase the value of bill_number by one in the database. Please help me as soon as possible. set @bill_number = @bill_numer+1; This is the query I've tried before but it's not working.
user2827435
1

votes
1

answer
394

Views

php to AJAX form submission

Newbie here in AJAX i got this code, Please help, my code keeps going to the sec_reg.php page even if the password is mismatch, or even when the form is valid, i want the user to stay on current page even if he submits a form. Here is my code Here is my form ADD ANOTHER ADMIN Email Password Confirm...
user3196424
1

votes
1

answer
20.9k

Views

Php Result page to be displayed on same page

This is my coding for the search form: Search The thing is , When I submit this form on my web page , It goes to the php Results page and displays the results. But the thing is that it is just a plain page with just the results displayed. My search page : www.mysite/test/certification-database-sear...
Nau Nau head
1

votes
2

answer
5.2k

Views

How to insert long Strings into mySQL database using PHP?

I'm using a simple html-form and PHP to insert Strings into mySQL Database, which works fine for short strings, not for long ones indeed. Using the phpmyadmin I'm able to insert Strings of all lengths, it's only doesn't work with the html file and PHP. Will appreciate every kind of help, would love...
lifelover
1

votes
2

answer
61

Views

Building nested arrays in PHP

So I'm trying to build a JSON object with an array nested inside the main users array. I'm having a bit of trouble building the data model in the PHP. Can anyone give any pointers? Desired output: [{ id: 2, name: "John Wilson", profilePic: "fighter-1.jpg", activities: [{ id: 6431, time: (57).minut...
user2656127
1

votes
1

answer
1.3k

Views

Fetch column name and rows data from mysql and create json

Here I have an database mysql: I need to make a json file in this format: {"cols":[{"label":"ID","type":"number"},{"label":"Naziv","type":"string"},{"label":"Povrsina","type":"number"},{"label":"Lokacija","type":"string"},{"label":"Arkod ID","type":"number"},{"label":"Osnov koriscenja","type":"strin...
gmaestro
1

votes
5

answer
609

Views

Strange slow queries with MySQL

I have table A which contains IP ranges (columns startIpNum, endIpNum, locId) and table A_location (column locaId and other not important columns). There are following indexes - startIpNum and endIpNum on A, and locId on A_location. The problem is that sometimes queries are performed very slowly. Be...
2

votes
0

answer
44

Views

Delete all except those specified

I have a program that sends an entry to my php script which is then added to the database and is updated instead if it already exists The program sends around 3000 entries and the php script saves the ids into a text file, after all the entries were sent the php script should delete all of the entr...
Fakku
0

votes
2

answer
22

Views

Is there better way to get the difference between two table with same fields?

I have two tables as below: table1: +----+----------+-------+ | id | order_id | price | +----+----------+-------+ | 1 | 1024 | 20 | | 2 | 1025 | 30 | | 3 | 1026 | 35 | | 4 | 1027 | 45 | +----+----------+-------+ table2 +----+----------+-------+------+ | id | order_id...
jia Jimmy
0

votes
0

answer
21

Views

Populate data of one table to another one

I have a tables like: table1: table2: I want to insert those data of table2 in the table1. What I need to do is if flag is 2, then I need to insert them in columns phone_number, phone_type, ph_start_date, ph_end_date. But if flag is not 2 then I need to insert phone number in ud1, ud2, ud3,...
sam1721
0

votes
1

answer
15

Views

How to write raw query in Laravel

I need to write a raw query in Laravel Database: Query Builder, That outputs size of specific table In core mysql query is as following SELECT table_name "Name_of_the_table", table_rows "Rows Count", round(((data_length + index_length)/1024/1024),2) "Table Size (MB)" FROM information_schema.TABLES W...
Hemant Maurya
0

votes
0

answer
16

Views

PostgreSQL Database Log Transaction

I'm a last year college student and I'm doing my thesis right now. My title is "Index Suggestion based on Log Analysis". This project will analyze the PostgreSQL transaction log to give index recommendation to the database that will be tested. This research will develop an index recommender tool by...
wdwilhelmina

View additional questions