Search Posts

Month: January 2018

[HELP] I am trying to pput data from a csv file into my table but I keep getting an error saying "data too long for column Course at row 2"

use mysql; create database ReviewDB; use ReviewDB; create table Reviews ( Course varchar(20), Communication int, Email int, Discussions int, Graded_Tests int, Graded_Assignments varchar(4), Availability int, Course_Activities varchar(4), Course_Policies int, Strengths char(150), Improvements varchar(10000) ); LOAD DATA infile "Documents/reviews/reviews.csv" into table Reviews Fields TERMINATED BY ',' LINES TERMINATED BY ';' (Course,Communication,Email,Discussions,Graded_Tests,Graded_Assignments,Availability,Course_Activities,Course_Policies,Strengths,Improvements); I have no idea how to fix it. I tried fixing the csv file itself but that doesnt work. submitted by /u/pollosucio [link] […]

Help with a query in a column using CONTAINS

Hello, I'm trying to do a query of a phone call log database where the column I'm querying contains a string of characters, but I can't query the EXACT string, I only want to query a string that CONTAINS what I'm looking for. Specifically, the column name is "dst" and I'm looking for numbers that contant "011". By the way, I'm not sure if it matters, but the strings in this column are always contained […]

MariaDB Bitwise AND (&) operation

In my project, product Software architecture with 32 and 64 bits are stored in table as 21 and 22 respectively for various products. I came across a SQL in which ‘where‘ clause mentioned as for architecture 22 ‘architecture & 2 = 2’; and for architecture 21 ‘architecture & 2 != 2’; I am not able to understand significance of above statements and what 2 = 2 doing in this SQL? Source: Stackoverflow MariaDB

Mysql – LEFT JOIN way faster than INNER JOIN

I have two tables Table X: millions or records |—–|—–|—–|—–| | a | b | c | d | |—–|—–|—–|—–| Table Y: only a few records |—–|—–| | e | f | |—–|—–| X.d allows me to join both tables on X.d = Y.e I have the following indices: (X.a) (X.b) (X.c) (X.d) (X.a, X.b, X.c, X.d) (Y.e) One of our application was executing the following query, which took ages to run: SELECT * FROM […]

html – PHP Auto update selectbox with SQL Data based on 1st selectbox choice

I’m working on a website where you need to choose Region/Province/District. Region,province and district’s name are stored in SQL different tables. After you click an option of the first selectbox (with regions) the 2nd selectbox is gonna auto-update with the provinces of that region (tables in SQL are linked, queries are not a problem), and so on with the 3d selectbox Source: Stackoverflow

Laravel relationships changing table columns makes undefined property

So I changed the name of a column in my Laravel app and the party started.. The change was from name_id to seller_id Before in view: $transaction->user->first_name Before in controller Transaction: class Transaction extends Model { public function user(){ return $this->belongsTo(‘AppUser’); } } After in view: $transaction->seller->first_name After in controller Transaction: class Transaction extends Model { protected $primaryKey = ‘seller_id’; public function user(){ return $this->belongsTo(‘AppUser’); } } After returns: Trying to get property of non-object […]

Codeigniter- Setting id of the other table be equal to id of another table

I’m stuck with setting the existing customers id be equal to the purchase id. This is model for entry. On the else block, the error says: “Message: Object of class CI_DB_mysqli_result could not be converted to string” and error on this line: “$purchase[‘cust_id’] = $cust;”. I’m a beginner in php and Codeigniter Class Entry_m extends CI_Controller{ public function create_submit($customer, $purchase){ $array = array(‘lname’ => $customer[‘lname’], ‘fname’ => $customer[‘fname’], ‘mn’ => $customer[‘mn’]); $this->db->like($array); $query = $this->db->get(‘customer’); […]

Nodejs Mysql Weired Behaviour

I am trying to enter data in a database. When I have less files it works fine but when the files increase I get weired behaviour. The “checkElement” function is called but it does not enter anything into the database no execute the getconnection. Is this a race condition? If so, how can it be remedies? everyXtime(); function everyXtime(){ dir.files(__dirname+”/data”, function(err, files) { if (err) throw err; console.log(files); // has about 500 files. processFilesNames(files); }); […]

Next Page »