multiple-tables

2-table interaction: insert, get result, insert

喜夏-厌秋 提交于 2019-12-11 01:53:49
问题 I need to make a fundamental decision of my database/web interaction and I am missing the knowledge to even find proper search terms. Background: I am building a family website which supports a forum, family tree, pvp games with rankings and more details, all from a datamodel. Technologies right now: Php, MySQL, javascript in object oriented fashion. Requirement: In a forum datamodel, process a written post as addition of a new forum topic (thread). Current approach: In my current datamodel

Select total of childrens in multiple tables in one query with mysql

醉酒当歌 提交于 2019-12-10 19:01:33
问题 All my afternoon was consumed trying to deal with a query (or two or three) in order to get the count of all childs of three tables. Take a look to my design: user table id_user | name 1 | foo 2 | bar wons table id_won | user 1 | 1 2 | 1 3 | 2 draws table id_draw | user 1 | 1 2 | 2 3 | 2 loses table id_lose | user 1 | 1 2 | 1 3 | 1 I'm trying to get something like this: name | wons | draws | loses foo | 2 | 1 | 3 bar | 1 | 2 | 0 This is my try: select u.name, w.total_w, d.total_d, l.total_l

SQL: Replace part of a column on multiple rows based on second table

烈酒焚心 提交于 2019-12-10 15:12:48
问题 I have a table ( pages ) that holds properties for web pages, including a column for the page content itself, an NVARCHAR(MAX) column. Within that column, I need to find and replace a bunch of text strings and replace them with other text strings; these correlations are in a second table ( moving ), with an oldValue and newValue column. So, for example, if I'm starting with the two tables like this: pages table: ID Content 1 Words words Ancient words 2 Blah blah OutWithTheOld blah 3 Etc etc

MySQL select DATETIME similar up to the minute

限于喜欢 提交于 2019-12-10 12:58:58
问题 I have to comapre the results relative to the same time between two tables, but the time stamps differs of some second because of how they were recorded. I would like to obtain a result like in Example 1 but I get only the values with the asterisk, as in Example 2 . What is the best way to remove the secods from the comparison, or to select the value corresponding to the closest DATETIME value? Currently I'm using this query: SELECT Table1.TimeSTamp1, Table1.Param1, Table2.TimeStamp2, Table2

iOS program to use multiple UITableView in a single UIViewController

早过忘川 提交于 2019-12-09 03:19:02
问题 I am trying to implement 3 tables in a single segue in a storyboard. When one table is selected it will unhidden a view with another table and likewise one more. The following code i have used for one table the cell format of each table is different and rows also vary. So how can i DIFFERENTIATE between each table by coding to set different number of rows for each table and so on? -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { return 1; } -(NSInteger) tableView:

Delete from table if the id doesn't exists in another table

我怕爱的太早我们不能终老 提交于 2019-12-08 18:01:06
问题 I want to delete the id's from types that can't be found in types_photos but I don't know how I can accomplish this. id_type in types_photos are the same as id in types . Here's how the table's structure looks like: CREATE TABLE IF NOT EXISTS `types` ( `id` int(11) NOT NULL AUTO_INCREMENT, `id_user_added` int(11) DEFAULT '0', `id_user_edited` int(11) DEFAULT '0', `data_name` text NOT NULL, `data_name_seo` text NOT NULL, `data_type` enum('tag','equipment','search') NOT NULL, `datetime_added`

Listing data from mysql tables

爷,独闯天下 提交于 2019-12-08 00:49:33
问题 recipe_category cid | category 1 | desserts 2 | cakes 3 | biscuits recipe_name id | recipe_name | cid | iid 1 | black forest cake | 1,2 | 1,2,3,4 2 | angel cake | 2 | 1,2,4 3 | melting moments | 3 | 2,5 4 | croquembouche | 1,3 | 1,5 ingredients iid | ingredient_name 1 | self-raising flour 2 | milk 3 | chocolate 4 | baking powder 5 | plain flour I am able to query the DB using cid to pull certain recipes, ie. desserts: SELECT * FROM recipe_name WHERE cid='1' But then how do I create a list of

Joining 3 tables and retrieve all the records from all the tables

梦想与她 提交于 2019-12-07 18:52:12
问题 I am joining three tables (performing a full outer join) so that I can retrieve all the records from all the tables. Problem that I am facing is with the order in which I join tables. Table Information alt text http://img235.imageshack.us/img235/7980/tableinfoow1.png (1) If I join tables in TABLE1, TABLE2, TABLE3 sequence I get two rows for record with team B and Level 1. SELECT DISTINCT (CASE WHEN T0.[TEAM] IS NOT NULL THEN T0.[TEAM] WHEN T1.[TEAM] IS NOT NULL THEN T1.[TEAM] WHEN T2.[TEAM]

How to do Outer Join on >2 Tables (Oracle)

你离开我真会死。 提交于 2019-12-07 01:24:37
问题 I'm not sure how to describe my table structure, so hope this makes sense... I have 3 tables in hierarchical relationship such that A has a one to many relationship to B which in turn has a one to many relationship with C. The trick is that the foreign key in B and C are allowed to be null (i.e. no parent defined). I also have D and E with no relation to A, B or C (directly). Finally, I have F which is a join table with many to one relationships with C, D and E. None of its fields (FKs to the

SQL Server: Select from two tables and insert into one

蓝咒 提交于 2019-12-06 12:19:19
问题 I have a stored procedure with two table variables (@temp and @temp2). How can I select the values from both temp tables (Both table variables contain one row) and insert them all in one table ? I tried the following but this didn't work and I got the error that the number of SELECT and INSERT statements does not match. DECLARE @temp AS TABLE ( colA datetime, colB nvarchar(1000), colC varchar(50) ) DECLARE @temp2 AS TABLE ( colD int ) ... INSERT INTO MyTable ( col1, col2, col3, col4 ) SELECT