Menu
  • HOME
  • TAGS

Purging Database - Count purged/not-purged tables

mysql,sql,sql-server,database,stored-procedures

The only way to do this is to manually run a count(*) on all of your tables filtering on the particular date field. The reason for this is because one table might have a column "CreatedDate" that you need to check if it's >30 days old, while another might have...

Python Sqlite3: Create a schema without having to use a second database

python,database,sqlite,sqlite3

The main database is always named main, you cannot change that name. You can just create an in-memory database and attach your database to that using an arbitrary name: conn = sqlite3.connect(':memory:') conn.execute("attach ? as 'schemaname'", (filename,)) However, if you are going to be using the database as a fallback...

IBM Cognos _days_between function not working

mysql,database,date,cognos

The Cognos _days_between function works with dates, not with datetimes. Some databases, like Oracle, store all dates with a timestamp. On a query directly to the datasource, try using the database's functions to get this data instead. When possible, this is always preferable as it pushes work to the database,...

ElasticSearch asynchronous post

database,post,asynchronous,elasticsearch,get

To ensure data is available, you can make a refresh request to corresponding index before GET/SEARCH: http://localhost:9200/your_index/_refresh Or refresh all indexes: http://localhost:9200/_refresh ...

Does Maria DB support ANSI-89 join syntax

sql,database,join,syntax,mariadb

Short answer - yes, both options are supported.

Is there a way to create a primary key and have it cascade into other tables without re-entering data into the new tables?

mysql,database,cascade

You can use a trigger to autofill another table. DELIMITER $$ CREATE TRIGGER init_cross AFTER INSERT ON item FOR EACH ROW BEGIN INSERT INTO `cross`(item,equip) VALUES( NEW.item, NEW.equip ); END; $$ DELIMITER ; ...

How to store the content for android application

android,database,sqlite

You could set-up a backend using some database (eg. MySQL) and some programming language (eg. PHP) as well as some kind of web-server (eg. Apache). You would store the products,user data in tables of the database. Pictures would be stored on some directory on your server and you could store...

How to use existing SQLite database in swift?

ios,database,xcode,sqlite,swift

First add libsqlite3.dylib to your Xcode project (in project settings/Build Phases/Link Binary with Libraries), then use something like fmdb, it makes dealing with SQLite a lot easier. It's written in Objective-C but can be used in a Swift project, too. Then you could write a DatabaseManager class, for example... import...

How connect database class with an array connect

php,database,database-connection

You've defined constants, so there is no need to wrap it in quotes, or concatenation. Using quotes would be treated as a string literals. $config = array(); $config['database']['host'] = DB_HOST; $config['database']['user'] = DB_USER; $config['database']['password'] = DB_PASS; $config['database']['database'] = DB_NAME; References: http://php.net/manual/en/language.constants.php https://php.net/language.types.string ...

MySQL: Select several rows based on several keys on a given column

mysql,sql,database

If you are looking to find the records matching with both the criteria here is a way of doing it select `item_id` FROM `item_meta` where ( `meta_key` = 'category' and `meta_value` = 'Bungalow' ) or ( `meta_key` = 'location' AND `meta_value` = 'Lagos' ) group by `item_id` having count(*)=2 ...

Golang ORDER BY issue with MySql

mysql,database,go

Placeholders ('?') can only be used to insert dynamic, escaped values for filter parameters (e.g. in the WHERE part), where data values should appear, not for SQL keywords, identifiers etc. You cannot use it to dynamically specify the ORDER BY OR GROUP BY values. You can still do it though,...

SQLITE_BUSY error in iOS application

ios,database,swift,sqlite3

I believe you forget finalizing your prepared statements using sqlite3_finalize(), unless you have unmatched open/close calls or you access the db connection from multiple threads. According to sqlite guidelines: If the database connection is associated with unfinalized prepared statements or unfinished sqlite3_backup objects then sqlite3_close() will leave the database connection...

What type of database is the best for storing array or object like data [on hold]

database,node.js,sockets

Redis would probably be fastest, especially if you don't need a durability guarantee - most of the game can be played out using Redis' in-memory datastore, which is probably gonna be faster than writing to any disk in the world. Perhaps periodically, you can write the "entire game" to disk....

Calculations between 2 records of 2 tables need to extend to more then 1300 fields. How and which database can achieve this?

database,postgresql,database-design

As an example to my comment above, using an array rather than discrete fields for each value: create table tablea ( id int not null, a numeric[] ); create table tableb ( id int not null, b numeric[] ); insert into tablea select 2, array (select generate_series(1,10000)); insert into tableb...

Memsql, Is it possible to add more leaf nodes on the same host machine?

database,cluster-computing,memsql

As the error suggests, web ui doesn't support adding more leaves on the same machine. However, you can add more leaves on the same machine via command line: memsql-ops memsql-deploy --role leaf --port 9000 While web-ui cannot add a new leaf, it will be able to manage it once it...

How to add +1 value to php

php,html,ajax,database

There are a number of problems in your code, but the one that causes the actual problems you're having is the fact that your function pie does not increment the values you fetched from the DB, that's done outside of the function, but the incremented values aren't used there: function...

If I export my database with phpmyadmin will it lock my tables or take my database down?

mysql,database,phpmyadmin

The answer is no, tables won't be locked, database won't be down. But, if your database is large and it takes long time to backup it, you can sometimes expect performance degradation(slow SQL queries from your application).

Id in database using qt

database,qt,sqlite

The method you're looking for is QSqlQuery::lastInsertId(). To quote the documentation: Returns the object ID of the most recent inserted row if the database supports it. An invalid QVariant will be returned if the query did not insert any value or if the database does not report the id back....

Complex SQL with Multiple Joins

mysql,database,join

What I think you should take note of here is that each post has a department and a postType. If you take a step back, you can select all posts that belong to a certain department and a certain postType like this: SELECT p.* FROM posts p JOIN department d...

In simple RESTful design, does PATCH imply mapping to CRUD's (ORM's) “update” and PUT to “destroy”+“create” (to replace a resource)?

database,rest,http,orm,crud

Well, Both the actions actually means update, where PUT is full update and PATCH is partial update. In case of PUT you already know the identifier of the resource and the resource already exists, so it is not a create and delete action per se. Infact, you can make do...

Prevent upvote model from being called for every comment

ruby-on-rails,ruby,database,performance,model

Assuming you have properly set relations # user.rb class User has_many :upvotes end we can load comments, current user and his upvotes: # comments_controller.rb def index @comments = Comment.limit(10) @user = current_user user_upvotes_for_comments = current_user.upvotes.where(comment_id: @comments.map(&:id)) @upvoted_comments_ids = user_upvotes_for_comments.pluck(:comment_id) end And then change if condition in view: # index.html.erb <%...

ElasticSearch - how to get the auto generated id from an insert query

c#,mysql,database,elasticsearch,nest

You can find the id values from the ISearchResponse (based on your code example above) by looking at the objects in the Hits collection, rather than the Documents collection. Each Hit has an Id property. In the original indexing call (assuming you're doing that individually -- not via the _bulk...

Database object with different data

sql,asp.net,asp.net-mvc,database,entity-framework-6

Ideally what you want is a many-to-many relationship between your Shop and Product entities: public class Shop { public int ShopId {get; set;} public virtual ICollection<ShopProduct> ShopProducts {get; set;} } public class Product { public int ProductId {get; set;} public string Name {get; set;} public virtual ICollection<ShopProduct> ShopProducts {get; set;}...

Hikari connections and active AS400 jobs

java,database,ibm-midrange,hikaricp

The point of a connection pool is to remove the overhead of establishing connections to the database. It does this by maintaining a "pool" of constantly alive connections, ready for use. If your workloads are "spikey" with long periods of no activity, but occasional periods of lots of activity, I...

How to copy all database users from one database to another [closed]

sql,sql-server,database

You cannot just use an INSERT .... SELECT construct. You need to use the sys.users info to generate CREATE USER statements and execute those statements. If this is a one time thing, I would use select 'CREATE USER [' + uu.name + '] FOR LOGIN ' + ll.name + '...

How To Get the Sum of a Column within a given Date range in a Table and Update a particular Cell in The Table with The Sum in TSQL?

sql-server,database,tsql,stored-procedures

You are using a cursor, to start with... I would go with an update statement using a join to a derived table. Something like this should do the trick: UPDATE t1 SET TInterest = SumTInterest FROM PersonalLedgerForTFundAndShareClone t1 INNER JOIN ( SELECT EmNo, SUM(TInterest) AS SumTInterest FROM PersonalLedgerForTFundAndShareClone WHERE TDate...

findOrFail laravel 5 function for specific filed

database,laravel,view,eloquent

You could create the behaviour you are looking for with the following: Geo_Postal_us::where('postal', $postal)->firstOrFail(); ...

C# Storing player cards Database Design

c#,mysql,sql,database,database-design

You can Add another table to reduce repeated data for player name card_table -> [card_id], [cardName] player_table -> [player_id] , [playerName] player_card_table -> [player_id],[card_id],[qty] Hope this will help :)...

Dgrid - Display label for number (i.e. 02 = Cat) I want to display Cat - not the number

javascript,database,dojo,dgrid

You need to use the column formatter function for rendering data. check the jsfiddle over here. Check the examples over here I have taken this example and modified as per your needs. require([ 'dgrid/Grid', 'dojo/domReady!' ], function(Grid) { var data = [ { id: 1, number: 7 }, { id:...

How to get node.js to connect to mongolab using mongoose

database,node.js,mongodb,mongoose,mongolab

Try using db = mongoose.connect(uri); instead of db = mongoose.createConnection(uri); ...

Creating a generic / abstract “DBContext” Class for shared functionality among different DBs

c#,database,generics,inheritance,abstract-class

The key here is to step back and think about the problem from another angle. You are duplicating lots of code because you are creating instances of the database and command classes within the method. So inject them instead: public class SomeDBClass { static DataTable exec_DT(DBConnection conn, DBCommand cmd) {...

ODBC ISAM_EOF without any reason

c#,database,odbc,cobol

It seems to be Windows UAC reliant. As our application run in compatibility mode, UAC visualization is active and causing may some problems. The reason for this is, that the COBOL databse is a file based database, and the client where are coding for uses these files in ODBC DSN...

Desktop Database with Server without installation

java,database,server,desktop,h2

Like Jayan told me in a comment to my question embedded mode does accept a location to save the data.

SQL checking for NULL fields

php,mysql,database,pdo

I knew there were fields that were empty that should have caught the check, but they were empty rather than NULL. So, when I was checking for NULL fields, it didn't find any. What I had to do was set all the empty columns to NULL: UPDATE `table` SET `column`...

SQLite: Individual tables per user or one table for them all?

database,sqlite

In an object oriented language, would you make a class for every user? Or would you have an instance of a class for each user? Having one table per user is a really bad design. You can't search messages based on any field that isn't the username. With your current...

Extracting data from Excel to Access Database

database,excel,ms-access,ms-word

Translate that form into Excel. Use "Collect Data" under the "External Data" tab on the ribbon to collect data from customers. To pull data onto your spreadsheet from Access do something like this. Use an Excel spreadsheet for the form. Then make a command button with the following event on...

Database only adds (x) amount of rows before error system resources exceeded

database,vb.net,ms-access

You should change your code to something like the following. Note that Everything that returns an object like OleDbConnection, OleDbCommand, or OleDbDataReader is wrapped in a Using block. These objects all implement the IDisposable interface, which means they should be cleaned up as soon as you're done with them. Also...

How To Implement A Recent History Table

mysql,database

I would update, otherwise you keep adding more and more data which you are not going to use. Maybe you won't run into problems with this specific case (because people won't select tens of thousands of persons a day), but in general you should be careful with just adding data...

Why am getting this error?: Unknown column 'firstname' in 'field list'

php,database,mysqli

$query = "INSERT INTO `myDatabaseForAll`.`users` (`id`, `firstname`, `lastname`, `username`, `password`) VALUES (NULL, $firstname, $lastname,$username,$password)"; you need single quote around text feilds in sql queries change above query to $query = "INSERT INTO `myDatabaseForAll`.`users` (`id`, `firstname`, `lastname`, `username`, `password`) VALUES (NULL, '$firstname', '$lastname','$username','$password')"; ...

Speeding up a SQL query with indexes

sql-server,database,performance

The best thing to do would depend on what other fields the table has and what other queries run against that table. Without more details, a non-clustered index on (code, company, createddate) that included the "price" column will certainly improve performance. CREATE NONCLUSTERED INDEX IX_code_company_createddate ON Products(code, company, createddate) INCLUDE...

Extremely basic SQL Misunderstanding

mysql,database

Your query will list non-existing jobs in case the database has orphan records in applicant and qualified, and might also omit jobs that have no qualified and willing candidates. I'm not exactly sure, because I have no idea if there's any database that will accept COUNT(a-id) when there's no information...

How to connect and access mssql Database server from Android app? [closed]

android,sql-server,database

Wow this is a really complicated!! The apps can't connect directly with server how do websites... Remember the devices it's possible lose internet, then how you connect with you server database? The most important of devices is can work offline, in this moment our app needs a webservice (API) to...

Does MongoDB find() query return documents sorted by creation time?

database,mongodb,sorting

No. Well, not exactly. A db.collection.find() will give you the documents in the order they appear in the datafiles host of the times, though this isn't guaranteed. Result Ordering Unless you specify the sort() method or use the $near operator, MongoDB does not guarantee the order of query results. As...

select data according to Row in Sqlite

android,database,sqlite,android-sqlite

you can do it just like below code public void rec(int _id){ String query = "SELECT * FROM notesDb WHERE PhoneNumber =" + _id; SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery(query, null); if (cursor.moveToFirst()) { do { String temp_address = c.getString(0); String temp_address1 = c.getString(1); System.out.println(temp_address); System.out.println(temp_address1); } while...

ER diagram for booking database

database,database-design

typically, you would store the password as some sort of encrypted hash. It is best if this is one-way, so it cannot be decrypted. When authenticating, you check that you can generate the same hash from the provided password; not decypt what is stored. Your hash should also be "salted"...

Order by count not sorting the records correctly?

php,mysql,database

Try this SELECT count(receiver_id) as total_receiver FROM gr_group_memberships INNER JOIN gr_group on gr_group_memberships.group_id = gr_group.id GROUP BY gr_group_memberships.receiver_id ORDER BY gr_group_memberships.receiver_id DESC I think it will worked what you want...

docker run local script without host volumes

database,shell,docker,docker-compose

The solutions I have found are: docker run tomdavidson/initdb bash -c "`cat initdb.sh`" and Set an ENV VAR equal to your script and set up your Docker image to run the script (of course one can ADD/COPY and use host volumes but that is not this question), for example: docker...

CakePHP Unable to insert to database (datetime format)

database,datetime,cakephp,insert

Your problem is in view :) Change report to Report. Now when you are saving $this->request->data its trying to find Report key to be able to save , or report field in your database. If you dont want change this , in controller you can save $this->request->data['report'] Edit Also if...

Difference between dba_SEGMENTS and dba_data_files

mysql,sql,database,oracle11g,oracle-sqldeveloper

Oracle uses "logical" und "physical" structures to store the data. For this case: The extents of a segment can be stored in different datafiles, so just summing up can work but must not work see here: http://docs.oracle.com/cd/E11882_01/server.112/e40540/logical.htm#CNCPT301 Plus: Oracle has a "High Water Mark" so even if your segment size...

Access Database Total Field not calculates empty records?

sql,database,ms-access-2007,ms-access-2010

SELECT reservations.customerid, (SELECT SUM (balances.balance) FROM balances WHERE balances.customer_id = reservations.customerid) AS Preveious_balance , (SELECT SUM(services.Amount_due) FROM services WHERE services.customer_id = reservations.customerid AND services.status=0) AS Service_due , (SELECT SUM(foods.Amount_due) FROM foods WHERE foods.customer_id = reservations.customerid AND foods.status=0) AS Food_due, ((due_nights.Due_nights - reservations.billed_nights) * rooms.rate) as Accomendation, (NZ(Preveious_balance,0) + NZ(Service_due,0)...

creating stored procedure in mysql calculate profit from product table

mysql,sql,database,stored-procedures

You forgot the () after the procedure name. Also, you should set a delimiter: DELIMITER // CREATE PROCEDURE sp_profit() BEGIN SET @v1:= (select sum( cost_price * current_stock) from product); SET @v2:= (select sum( selling_price * current_stock) from product); SELECT (@v2 - @v1); END; // ...

Pull information from SQL database and getting login errors

php,sql,database

change $username = "'rylshiel_order"; to $username = "rylshiel_order"; and you should be through. You are passing on an extra single quote here. ...

normalization of database structure

mysql,database,database-design,database-schema

I would use case one but with some changes. The parameter entity does hold one thing, parameters for a table. An instance of a parameter entry should relate to only one table (based on your analysis that they are not related). Parameter ---------- PK Param_ID FK Main_Table_ID Main_Table_name (A or...

Foreign key in C#

c#,sql,sql-server,database

You want create relationship in two table Refer this link http://www.c-sharpcorner.com/Blogs/5608/create-a-relationship-between-two-dataset-tables.aspx...

Elasticsearch and C# - query to find exact matches over strings

c#,.net,database,elasticsearch,nest

You can use filtered query with term filter: { "filtered": { "query": { "match_all": { } }, "filter": { "bool" : { "must" : [ {"term" : { "macaddress" : "your_mac" } }, {"term" : { "another_field" : 123 } } ] } } } } NEST version (replace dynamic...

SQL Server: checkident: “[S00014][2560] Parameter 3 is incorrect for this DBCC statement.”

sql-server,database

https://msdn.microsoft.com/en-us/library/ms187745.aspx Turns out the ID field was a smallint which can only go to 32767. It was overflowing....

replacing vales in one table with values from another table using multiple criteria

sql-server,database,sql-update,inner-join

Check Below code it will work for sure , Update jc set jc.accno = ac.accnonew,jc.jno =ac.accnonew,jc.saccno =ac.saccnonew from jobcost jc join accadj ac with(nolock) on jc.accno = ac.accnoold and jc.jno = ac.jnoold and jc.saccno =ac.saccnoold Thanks...

How do I prevent MySQL Database Injection Attacks using vb.net?

mysql,.net,database,vb.net,sql-injection

MySQLCon.Open() Dim SQLADD As String = "INSERT INTO members(member,gamertag,role) VALUES(@memberToAdd, @memberGamingTag, @memberRole)" COMMAND = New MySqlCommand(SQLADD, MySQLCon) COMMAND.Parameters.AddWithValue("@memberToAdd", memberToAdd.Text) COMMAND.Parameters.AddWithValue("@memberGamingTag", membersGamertag.Text) COMMAND.Parameters.AddWithValue("@memberRole", membersRole.Text) COMMAND.ExecuteNonQuery() memberToAdd.Text = "" membersGamertag.Text = "" membersRole.Text = "" MySQLCon.Close() MySQLCon.Dispose() You don't need to use...

Export database from a remote server into a specific folder on my computer

php,mysql,database,shell,command-line-interface

You can run mysqldump -h yourhostname -u youruser -p yourdatabasename > C:\your\file\path.sql -h connects you to the remote servers IP so you can dump the data locally, as long as your user has the correct privileges and you can connect remotely to your database server. However, you may need to...

Improving work with SQL DataTime

sql,sql-server,database,tsql

You can do it like this: SELECT IIF(DAY(@A) >= 25, DATEADD(d, 25 - DAY(@A), @A), DATEADD(d, 25, EOMONTH(@A, -2))) Here's a sample fiddle as well: sqlfiddle Note: EOMONTH requires SQL Sever 2012 or above - it returns the End-Of-Month date given a start date and a month offset....

PHP mysql field 1 plus field 2 * 5 wrong result [closed]

php,html,mysql,database,html5

You need to multiply earning per unit (($product['sellingprice'] - $product['cost'])) by the amount of stock ($product['stock']): <?php echo number_format(($product['sellingprice'] - $product['cost']) * $product['stock'],0,',','.'); ?> ...

Sharing database between android and windows phone

java,android,database,windows-phone

Sure! Host a WebService for sharing data amongst devices. Using a simple php script to insert and select will allow you to achieve this. Something like this blog would help develop understanding of web services if you want a place to start....

How to update SQL table from other table when they are on different servers

sql,sql-server,database,merge,sql-update

You need to use this syntax when updating with a join: UPDATE s SET s.[columnName] = l.[columnName] FROM [Server].[ServerDB].[dbo].[tableName] s INNER JOIN [LocalDB].[dbo].[tableName] l ON l.id = s.id ...

Reading a database diagram

mysql,database,diagram

This should work: SELECT products.* FROM products, product_category WHERE product_category.categoryid = CATEGORY_ID AND products.catalogid = product_category.catalogid Or if you prefer a join: SELECT products.* FROM products INNER JOIN product_category ON products.catalogid = product_category.catalogid WHERE product_category.categoryid = CATEGORY_ID Simply replace CATEGORY_ID by the ID of the category you wish to select....

Why does the date doesn't match with what I have inserted into the database?

sql,database,oracle

In the TO_DATE function you have to keep the format. The first parameter is the data and the second parameter is the format you are putting it. For example: to_date('29-Oct-09', 'DD-Mon-YY') to_date('10/29/09', 'MM/DD/YY') to_date('120109', 'MMDDYY') to_date('29-Oct-09', 'DD-Mon-YY HH:MI:SS') to_date('Oct/29/09', 'Mon/DD/YY HH:MI:SS') to_date('October.29.2009', 'Month.DD.YYYY HH:MI:SS') So if you put TO_DATE('05-06-2015','yyyy/mm/dd HH24:MI:SS')...

Make connection string ADO.NET

c#,database,connection-string,oledb,sql-server-express

@paddy suggested me this site connectionstrings.com. It help me to find the correct string. It was: Provider=sqloledb;Data Source=.\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=SSPI; ...

echo both users

php,mysql,sql,database,loops

Why don't you just do it in one single query? Just replace the necessary table and column name, and variables/values/parameters to be bind in your query: $query = mysqli_query($conn, "SELECT first_name, last_name, description, role FROM `wp_usermeta` WHERE `first_name` = '$first_name' OR `last_name` = '$last_name' OR `description` = '$description' OR `role`...

Return One value if more than one Exsist

android,database,sqlite,android-sqlite

Just return the column you want: ArrayList<String> getAllNotes() { Cursor cursor; mDbHelper = mSqliteHelper.getWritableDatabase(); String query = "SELECT Distinct NOTES_COLUMN FROM " + SqliteHelpers.TABLE_NAME; cursor = mDbHelper.rawQuery(query, null); ArrayList<String> arrayList = new ArrayList<>(); while (cursor.moveToNext()) { String itemname = cursor.getString(cursor.getColumnIndex(SqliteHelpers.NOTES_COLUMN)); if (itemname != null) { arrayList.add(itemname); } } return arrayList;...

Combining two select statements

sql,database,select,where

Try to this var chgAssociationQuery1 = ((from a in sostenuto.PROBLEMS join b in sostenuto.S_ASSOCIATION on a.SERVICEREQNO equals b.FROMSERVICEREQNO join c in sostenuto.Changes on b.TOSERVICEREQNO equals c.SERVICEREQNO where b.FROMSERVICEID == 101001110 && b.TOSERVICEID == 101001109 && a.NAME.Contains(name) select new { ProblemReqNo = a.SERVICEREQNO, ProblemId = a.SERVICEREQID, ChangeReqNo = c.SERVICEREQNO, ChangeId =...

Displaying MySQL results in a single table

php,mysql,database

Try getting all the columns out first, then add it to the sql query, no need to loop the database query. $mark = $_POST['mark']; if (isset($_POST['mark']) && is_array($_POST['mark'])) { echo "<table border='1'>"; echo "<tr>"; for ($i = 0; $i < count($mark); $i++) { echo "<th>" . $mark[$i] . "</th>"; }...

sql script to find index's tablespace_name only

sql,database,oracle

SELECT DTA.* FROM DBA_TABLESPACES DTA, dba_indexes DI WHERE DI.TABLESPACE_NAME = DTA.TABLESPACE_NAME AND DI.OWNER ='USER' AND NOT EXISTS (SELECT 'x' FROM DBA_TABLES DTT WHERE DTT.TABLESPACE_NAME = DTA.TABLESPACE_NAME AND DTT.OWNER = DI.OWNER ); ...

HQL order by expression

java,sql,database,hibernate,hql

HQL doesn't support such a syntax, so you'll have to use a native query for this: List<Comment> comments = (List<Comment>) session.createSQLQuery( "select * " + "from Comment " + "where id in ( " + " select comment_id " + " from ( " + " select " + "...

Using a case statement to set the values of declared variables

sql,sql-server,database,tsql,case

You are on the right track, but syntax you've used is incorrect. It should be select @DeclaredVar1 = case when fieldValue ='stringValue1' then 100 else --another option here-- end ...

How to calculate number of days by subtracting date_time field from current date_time?

sql,database,ms-access,ms-access-2007

your query is wrong SQL SERVER the syntax for datediff is DATEDIFF(datepart,startdate,enddate) Also the function for getting current date in sql server is getdate() not now() so in your case it will be Select DATEDIFF(DAY,reservations.checkin_date, getdate()) eg:- select DATEDIFF(Day,'06-07-2015 14:00:00',GETDATE()) will return 10 MS-ACCESS DateDiff ( interval, date1, date2, [firstdayofweek],...

Using onUpGrade with multiple versions of App to add columns

android,database,sqlite

You need to make an if statement for each number if(oldVersion < 5) ... sql alter statement for the first new column ... if(oldVersion < 6) ... next sql alter statement ...

Check if value exists in MySQL DB in Java?

java,mysql,database,jdbc

I'd do this check in the where clause and use the Java side to simply check if this query returned any results: Connection con = DatabaseConnection.getConnection(); PreparedStatement ps = con.prepareStatement ("SELECT questid FROM completedQuests WHERE characterid = ? AND questid = ?"); ps.setInt (1, characterId); ps.setInt (2, questId); ResultSet rs...

How to rename a database in Web SQL?

sql,database,rename,web-sql

So there is no native way to do this. So the best answer should be: "select * from ..." each table you want to backup and iterate through results while inserting this data into new "backup" database. So there is no simpler way as "rename" or "backup". Thank you @Chuck...

Pandas sql update efficiently

python,database,pandas

The problem here is not pandas, it is the UPDATE operations. Each row will fire its own UPDATE query, meaning lots of overhead for the database connector to handle. You are better off using the df.to_csv('filename.csv') method for dumping your dataframe into CSV, then read that CSV file into your...

Android :: SQLIte Db don't insert the datas

android,database,sqlite

Your b is null. You didn't put anything in intent and you are fetching from intent. Put "score" in intent in SaveDataActivity then fetch from intent in ResultActivity. How to use putExtra() and getExtra() for string data...

What would be the fastest way to insert this data

mysql,sql,database,performance,csv

You can import the CSV file into a separate table using mysql LOAD DATA INFILE and then update the entries table using JOIN statement on the basis of similar column name. E.g: update entries a inner join new_table b on a.name = b.name set a.address = b.address ; Here new_table...

How I could create a db with the messages that are saved in admin/reports/dblog?

database,drupal,watchdog

Use function hook_watchdog(array $log_entry) { } where $log_entry is an array with all the log data you need. Read more: https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_watchdog/7...

PreparedStatement.executeUpdate() doesn't insert in sqlite database

java,database,sqlite

SOLVED: In a Maven Project, all the resources are copied into another directory after the "build" command. I was reading the wrong db.

string split and subquery in mysql

php,mysql,database

SELECT id FROM tags WHERE name LIKE ( SELECT CONCAT(SUBSTRING(name,1,5),'__',SUBSTRING(name,8)) FROM tags WHERE id=1 ) Returns 1,4 But Two queries (or a refactor) might be a better option...

SimpleMembershipProvider WebSecurity.InitializeDatabaseConnection The login from an untrusted domain

asp.net,database,exception,model-view-controller

I think that you are providing in your connection string UserName and password, so you can change from Integrated Security=True to Integrated Security=False and if the user 'DB_9CB321_Szklarnia_admin' has rights to connect it will work. When Integrated Security=True the userID and password will be ignored and attempt will be made...

What are Relational Objects?

database,jpa,persistence

A Query indeed returns instances of entities, but it can also simply return arrays (i.e. rows), or lists of objects that are not entities.

How do I access website databases? [closed]

database

In barely any case would you get direct access to another company's database, even if you are affiliated. The most common way would be an API (which might be public or licensed): https://en.wikipedia.org/wiki/Application_programming_interface If the data is publicly available on a website, some do content parsing although this is not...

get information in database and insert into session codeigniter

php,database,codeigniter,session

Model function get_user_info() { $user_email = $this->input->post('signin-email'); $this->db->select('acct_id, acct_fname, acct_lname, acct_mname'); $this->db->where('email', $user_email); $query = $this->db->get('account'); return $query->row_array(); // changed to row array } In Controller $user_info = $this->users_model->get_user_info(); // method does not have any arg $data = array( 'email' => $this->input->post('signin-email'), 'is_logged_in' => 1, 'user_info' => $user_info );...

Is there a way to implement a wcf service connected to a database without paying for azure?

database,wcf,azure,windows-phone-8

Here are some interesting articles about WCF Services in Windows Phone world. How to consume an OData service for Windows Phone 8 Using WCF Service in Windows Phone 8.1 (same in Windows Phone 8) Now you can host the WCF Service in your own server, hosting provider or anything else....

Multiply time with a decimal value in mysql?

mysql,database,stored-procedures

SEC_TO_TIME( TIME_TO_SEC( '00:04:18' ) * 1.7 ) = '00:07:18.6' SEC_TO_TIME( TIME_TO_SEC( '00:04:18' ) * 1.7 ) = '00:07:44.4'

Getting Multi Rows in Database and transferring it in a multiline textbox in VB.net WinForms

database,vb.net,winforms,textbox

I don't think you need to first query the db to get the count of records before then going back to the db to get the phonenumbers, you could just do this: mycom.CommandText = "SELECT Cellphone FROM tbl_applicant where Gender='Female';" myr = mycom.ExecuteReader While myr.Read() TextBox1.Text = TextBox1.Text & myr(0)...

what is the SQL prepared stament for lo_import in postgreSQL

c++,sql,database,postgresql,odbc

The query to prepare should be insert into test values(?,lo_import(?)); You proposal insert into test values(?,?) can't work because you can't submit a SQL function call (lo_import) as the value for a placeholder (?). Placeholders only fit where a literal value would fit. When you're asking what's the prepared statement...