Tag: mysql

Two foreign keys reference one table and null able foreign key

I am new to Database tables and relationships .I need some help for the below requirements Work flow 1. Hospital will have Male Patient 2. Hospital will have Female Patient 3. Hospital Will have Couple Patient but in RegTable it will stored as separate record for male and female. For the above requirements i have […]

Conditional probability p(y|x) in SQL

How to calculate conditional probability in vendor agnostic SQL code while reading a precomputed table (histogram) just once? Let’s imagine we have a query which returns a histogram relation. The histogram contains following attributes: {x, y, cnt}, where cnt is the count of occurrences of nominal attributes x and y. And calculation of the histogram […]

How to use python statement to check the sql table is exist or not.?

I would like to know how to write the python statement to check whether the sql table is exist or not. if the table is exist , then I will insert data to the table, otherwise, I will create the table. The table name is “resulttable”, db = MySQLdb.connect(“localhost”,”root”,”123″,”test”) cursor = db.cursor() sql=”””CREATE TABLE resulttable […]

Deploy Sql Changes to Customer Databases (altered tables, functions,…)

I am developing an application that uses a database (either PostgreSQL, MySQL, Oracle or MSSQL) on the customers system. Therefore I need to perform database updates with each new version. I am currently in the concept phase and have nothing running in production. All the DDL statements are in script files. The structure looks like […]

sql select and group by CURRENT_TIMESTAMP

I’m trying to select and group by date from MySQL. table looks like this: `id` int(11) NOT NULL, `run_data` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `date_day` varchar(20) NOT NULL, `number_of_links` int(20) NOT NULL, for selecting, I’m using: SELECT date_day, SUM(number_of_links) FROM my_table GROUP BY date_day DESC LIMIT 30 I’m getting total number of links per day […]

How can I get a Login from JSP page? How can I correct my jsp code.?

I’m wrong here How can I correct this String Sql=”select * from login where username='”+name+”‘ AND password='”+abc+”‘”; c1.st.executeQuery(Sql); { out.println(“aa”); } catch(SQLException ex) { I am only wrong here this is a login page in jsp.I am only wrong here this is a login page in jsp. db conn.jsp <%@page import=”com.mysql.jdbc.Connection”%> <%@page import=”com.mysql.jdbc.Statement”%> <%@page import=”java.sql.ResultSet”%> […]

How to combine two sql select statement

I have two SQL select statement that says SELECT TOP (150) FoodID, COUNT(*) AS NumberOfFood FROM FoodTable WHERE FoodID IS NOT NULL AND FoodDate >= ‘2015-10-01’ GROUP BY FoodID ORDER BY NumberOfFood DESC I also have another SQL statement SELECT FoodSellerID, Market1, SellerLastName, SellerFirstName, PrimaryAddress1, PrimaryAddress2, PrimaryCity, PrimaryState, PrimaryZip FROM SellerTable, MarketTable WHERE Market1= MarketTable.MarketID […]

Select property from max in cross apply SQL

I currently have this query SELECT OC.*, NEW.LAST_JOB_RUN_DATE FROM dbo.CUBES OC CROSS APPLY (SELECT MAX(LAST_END_RUN_DATE) AS LAST_JOB_RUN_DATE FROM dbo.JOBS OJ WHERE OJ.CUBE_ID = OC.ID) NEW Each CUBE can have multiple JOBS. I want this query to return me all the cubes, along with the last time the latest job was run. This works fine. Now […]

How to convert a local sql file to json with nodejs

I want to convert a local sql file ( backup.mysql, around 50mb ) to json format in node, I googled around on some plugins but no luck, most of them need a sql server to convert the data. Does any reader or plugin could convert a sql file to json? thanks! This is what my […]

Dynamic multi-database Context with Entity framework

I am working on an ASP.NET application that can interact with several database managers. So I decided to use entity-framework to successfully inter-act with these database managers.Currently my problem is that when I want to switch from one database to another I am forced to modify the constructor of the “DbContext”. For example, to use […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.