[Solved] How to join 3 and more tables in SQL?

Assuming that you have table 1, table 2 and table 3. Let´s create a simple example. table 1: employees: id, department_id, first_name, last_name, salary… table 2: departments: id, location_id, department_name… table 3: locations: id, city… department_id and location_id are foreign keys. Employees have a department_id and Departments have a location_id. You need this foreign keys … Read more

[Solved] Date/time comparison

You can create a function that returns the difference between two dates, run all the possible dates through this function, then pick the lowest difference. Something like this (pseudo c code) int array[numdates]; for (int i=0;i<numdates;i++) array[i]=compareDates(date[index], currentDate); Then you can sort the array so the lowest number is at the beginning (or end) and … Read more

[Solved] Sql schema error on create table [closed]

CREATE TABLE ar_abonent ( ar_nr_klienti int NOT NULL primary key , –<– This column needs to be a primary key emri varchar(25), mbiemri varchar(25) ); create table ar_celular ( NR_CEL INT , ar_nr_klienti int FOREIGN Key REFERENCES ar_abonent (ar_nr_klienti) , identifikues bit, data_aktivizimit date, marka varchar(25), constraint chk_celular check (NR_CEL IN (‘35566%’,’35567%’,’35568%’,’35569%’) AND IDENTIFIKUES= 1) … Read more

[Solved] SQL trouble with dots in data [closed]

Could you use a regular expression to match the URL? You didn’t include the query… /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/ The above would be a regular expression to match a URL including the https and double forward slash Numbers, letters, dots, and hyphens are included here. And in MySQL you could use this to match it: http://dev.mysql.com/doc/refman/5.1/en/regexp.html#operator_regexp solved … Read more

[Solved] Oracle: Multiple joins with group by [closed]

SELECT * FROM A; A_ID A_NAME A_ADDRESS ———- ———- ———- 1 RAM MO 2 SITA MI 3 JANAKI IL SELECT * FROM B; A_ID B_NAME ———- ———- 1 PAUL 1 KAPIL 2 DAVE SELECT * FROM C; B_NAME C_TITLE ———- ———- KAPIL HONDA KAPIL MAZDA KAPIL ODYSSY DAVE BENZE DAVE LIMOUSINE SELECT a.A_ID, a.A_Name, a.A_Address, … Read more

[Solved] Call the maximum from SQL table to textbox

You could design your database table using an IDENTITY column. The database will assign a next value for the inserted row. You can access the value using one of: SCOPE_IDENTITY, @@IDENTITY or IDENT_CURRENT. More can be found here: MSDN-Identity. To know the difference between SCOPE_IDENTITY and @@IDENTITY see here. solved Call the maximum from SQL … Read more

[Solved] redundant rows are then in answer

Looks like you want a GROUP BY with conditional aggregation: SELECT item_id, sum(case when from_where != ‘OPENING’ AND transaction_type=”C” then quantity end) as CREDITBAL, sum(case when from_where=”OPENING” then quantity end) as OPENBAL, sum(case when transaction_type=”D” then quantity end) as DEBITBAL FROM axi_quantity_registers group by item_id solved redundant rows are then in answer

[Solved] MySQL INSERT statement brings an error [closed]

Order is reserved word in MySQL, you can use back tick(`) around table name Also you can use MySQL NOW() function for date instead of PHP variable $date $t = “INSERT INTO `order` (order_date) VALUES (NOW())”; solved MySQL INSERT statement brings an error [closed]

[Solved] convert sql server file into mysql [closed]

The constraint lines in you output may define the constraints, eg: ALTER TABLE [dbo].[Message] WITH CHECK ADD CONSTRAINT [FK_Message_Message] FOREIGN KEY([OpratorID]) REFERENCES [dbo].[Oprator] ([ID]) says there is a relationship between Message and Operator ( Message.OperatorID = Operator.ID ) 0 solved convert sql server file into mysql [closed]

[Solved] How do I sort the list from database automatically according to the language? [closed]

You can change the way Oracle sorts data by changing the NLS_SORT and NLS_COMP parameter for your session. If you want to retrieve say french data, you can use the following: ALTER SESSION SET nls_comp = Linguistic; ALTER SESSION SET nls_sort = XFrench_AI; select * from my_table where language_code=”fr” order by some_column; Consequently if you … Read more

[Solved] MySQL: Return 2 different result together

SELECT qe.id, qe.content, a.id, a.content, a.dt, acr.checked, acr.score FROM `questions_and_exercises` qe, `questions from-to` qft LEFT JOIN `questions-answers` qa ON (qa.qid=q.id AND qa.uid=?) LEFT JOIN answers a ON (a.id=qa.aid) AND qft.to_lid=? AND qft.uid=? 2 solved MySQL: Return 2 different result together