Search Results

Search found 8943 results on 358 pages for 'audit tables'.

Page 40/358 | < Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >

  • How to write a JOIN statement to combine data from disparate tables

    - by Amarundo
    I have the following 2 procedures that I use as my source for a report. As of now, I'm presenting 2 different tables in my SQL Server Reporting Services 2008 R2 report, because it doesn't let me put them together as they belong to 2 different data sets. I want to present them in a single table, but I have not been successful trying to use JOIN here. How do I do that? NOTE: cName in IAgentQueueStats corresponds to UserId in AgentActivityLog. /*** Aggregate values for Call Center Agents for calls, talk and hold time ***/ /*** The detail/row values is per 30-minute interval ***/ ALTER PROCEDURE [dbo].[sp_IAgentQueueStats_OnlyCalls_Grouped] @p_StartDate datetime, @p_EndDate datetime, @p_Agents varchar(8000) AS SELECT [cName] ,sum([nAnswered]) SumNAnswered ,sum([nAnsweredAcd]) SumNAnsweredAcd ,sum([tTalkAcd]) SumTTalkAcd ,sum([nHoldAcd]) SumNHoldAcd ,sum([tHoldAcd]) SumTHoldAcd ,sum([tAcw]) SumTAcw FROM [I3_IC].[dbo].[IAgentQueueStats] WHERE dIntervalStart between @p_StartDate and DATEADD(s, 86400-1, @p_EndDate) AND CHARINDEX ( cName ,@p_Agents)> 0 AND cReportGroup <> '*' AND cHKey3 = '*' and cHKey4 ='*' AND nEnteredAcd > 0 AND cReportGroup <> 'CCFax Email' GROUP BY cName And here is the second one: /*** Aggregate values for Call Center Agents for status/activity time ***/ /*** The detail/row values is per start-time/end-time ***/ ALTER PROCEDURE [dbo].[sp_AgentActivity_Grouped] @p_StartDate datetime, @p_EndDate datetime, @p_Agents varchar(8000) AS SELECT [UserId],[StatusCategory],SUM([StateDuration]) [StatusDuration] FROM ( SELECT [UserId] ,[StatusGroup] ,[StatusKey] , CASE [StatusKey] WHEN 'Available' THEN 'Productive' WHEN 'Follow Up' THEN 'Productive' WHEN 'Campaign Call' THEN 'Productive' WHEN 'Awaiting Callback' THEN 'Productive' WHEN 'In a Meeting' THEN 'Not Your Fault' WHEN 'Project Work' THEN 'Not Your Fault' WHEN 'At a Training Session'THEN 'Not Your Fault' WHEN 'System Issues' THEN 'Not Your Fault' WHEN 'Test' THEN 'Not Your Fault' WHEN 'At Lunch' THEN 'Non Productive' WHEN 'Available, Forward' THEN 'Non Productive' WHEN 'Available, Follow-Me' THEN 'Non Productive' WHEN 'At Play' THEN 'Non Productive' WHEN 'AcdAgentNotAnswering' THEN 'Non Productive' WHEN 'Do Not Disturb' THEN 'Non Productive' WHEN 'Available, No ACD' THEN 'Non Productive' WHEN 'Away from desk' THEN 'Non Productive' ELSE [StatusKey] END StatusCategory ,stateduration FROM [I3_IC].[dbo].[AgentActivityLog] WHERE [StatusDateTime] between @p_StartDate and DATEADD(s, 86400-1, @p_EndDate) AND CHARINDEX ( [UserId] ,@p_Agents)> 0 AND [StatusKey] not in ('Gone Home','Out of the Office','On Vacation','Out of Town') ) a GROUP BY [UserId],[StatusCategory] ORDER BY [UserId], [StatusCategory] desc BTW, if I take some time to comment/reply on your posts, it's not lack of interest, but of understanding...

    Read the article

  • Make password case unsensitive in shared ASP.Net membership tables web ap

    - by bill
    Hi all, i have two webapps.. that share ASP.Net membership tables. Everything works fine except i cannot remove case-sensitivity in one of the apps the way i am doing it in the other. in the non-working app void Login1_LoggingIn(object sender, LoginCancelEventArgs e) { string username = Login1.UserName.Trim(); if (!string.IsNullOrEmpty(username)) { MembershipUser user = Membership.GetUser(username); if (user != null) { // Only adjust the UserName if the password is correct. This is more secure // so a hacker can't find valid usernames if we adjust the case of mis-cased // usernames with incorrect passwords. string password = Login1.Password.ToUpper(); if (Membership.ValidateUser(user.UserName, password)) { Login1.UserName = user.UserName; } } } } is not working. the password is stored as all upper case. Converted at the time the membership user is created! So if the password is PASSWORD, typing PASSWORD allows me to authenticate. but typing password does not! Even though i can see the string being sent is PASSWORD (converted with toUpper()). I am at a complete loss on this.. in the other app i can type in lower or upper or mixed and i am able to authenticate. In the other app i am not using the textboxes from the login control though.. not sure if this is making the difference??

    Read the article

  • Mysql count and sum from two diferent tables

    - by Agent_x
    Hi all, i have a problem with some querys in php and mysql: I have 2 diferent tables with one field in common: table 1 id | hits | num_g | cats | usr_id |active 1 | 10 | 11 | 1 | 53 | 1 2 | 13 | 16 | 3 | 53 | 1 1 | 10 | 22 | 1 | 22 | 1 1 | 10 | 21 | 3 | 22 | 1 1 | 2 | 6 | 2 | 11 | 1 1 | 11 | 1 | 1 | 11 | 1 table 2 id | usr_id | points 1 | 53 | 300 Now i use this statement to sum just the total from the table 1 every id count + 1 too SELECT usr_id, COUNT( id ) + SUM( num_g + hits ) AS tot_h FROM table1 WHERE usr_id!='0' GROUP BY usr_id ASC LIMIT 0 , 15 and i get the total for each usr_id usr_id| tot_h | 53 | 50 22 | 63 11 | 20 until here all is ok, now i have a second table with extra points (table2) I try this: SELECT usr_id, COUNT( id ) + SUM( num_g + hits ) + (SELECT points FROM table2 WHERE usr_id != '0' ) AS tot_h FROM table1 WHERE usr_id != '0' GROUP BY usr_id ASC LIMIT 0 , 15 but it seems to sum the 300 extra points to all users: usr_id| tot_h | 53 | 350 22 | 363 11 | 320 Now how i can get the total like the first try but + the secon table in one statement? because now i have just one entry in the second table but i can be more there. thanks for all the help. =============================================================================== hi thomas thanks for your reply, i think is in the right direction, but im getting weirds results, like usr_id | tot_h 22 | NULL <== i think the null its because that usr_id as no value in the table2 53 | 1033 Its like the second user is getting all the the values. then i try this one: SELECT table1.usr_id, COUNT( table1.id ) + SUM( table1.num_g + table1.hits + table2.points ) AS tot_h FROM table1 LEFT JOIN table2 ON table2.usr_id = table1.usr_id WHERE table1.usr_id != '0' AND table2.usr_id = table1.usr_id GROUP BY table1.usr_id ASC Same result i just get the sum of all values and not by each user, i need something like this result: usr_id | tot_h 53 | 53 <==== plus 300 points on table1 22 | 56 <==== plus 100 points on table2 /////////the result i need //////////// usr_id | tot_h 53 | 353 <==== plus 300 points on table2 22 | 156 <==== plus 100 points on table2 I think the structure need to be something like this Pseudo statements ;) from table1 count all id to get the number of record where the usr_id are then sum hits + num_g and from table2 select the extra points where the usr_id are the same as table1 and get teh result: usr_id | tot_h 53 | 353 22 | 156

    Read the article

  • mysql get table based on common column between two tables

    - by Zentdayn
    while trying to learn sql i came across "Learn SQL The Hard Way" and i started reading it. Everything was going fine then i thought ,as a way to practice, to make something like given example in the book (example consists in 3 tables pet,person,person_pet and the person_pet table 'links' pets to their owners). I made this: report table +----+-------------+ | id | content | +----+-------------+ | 1 | bank robbery| | 2 | invalid | | 3 | cat on tree | +----+-------------+ notes table +-----------+--------------------+ | report_id | content | +-----------+--------------------+ | 1 | they had guns | | 3 | cat was saved | +-----------+--------------------+ wanted result +-----------+--------------------+---------------+ | report_id | report_content | report_notes | +-----------+--------------------+---------------+ | 1 | bank robbery | they had guns | | 2 | invalid | null or '' | | 3 | cat on tree | cat was saved | +-----------+--------------------+---------------+ I tried a few combinations but no success. My first thought was SELECT report.id,report.content AS report_content,note.content AS note_content FROM report,note WHERE report.id = note.report_id but this only returns the ones that have a match (would not return the invalid report). after this i tried adding IF conditions but i just made it worse. My question is, is this something i will figure out after getting past basic sql or can this be done in simple way? Anyway i would appreciate any help, i pretty much lost with this. Thank you. EDIT: i have looked into related questions but havent yet found one that solves my problem. I probably need to look into other statements such as join or something to sort this out.

    Read the article

  • Many tables for many users?

    - by Seagull
    I am new to web programming, so excuse the ignorance... ;-) I have a web application that in many ways can be considered to be a multi-tenant environment. By this I mean that each user of the application gets their own 'custom' environment, with absolutely no interaction between those users. So far I have built the web application as a 'single user' environment. In other words, I haven't actually done anything to support multi-users, but only worked on the functionality I want from the app. Here is my problem... What's the best way to build a multi-user environment: All users point to the same 'core' backend. In other words, I build the logic to separate users via appropriate SQL queries (eg. select * from table where user='123' and attribute='456'). Each user points to a unique tablespace, which is built separately as they join the system. In this case I would simply generate ALL the relevant SQL tables per user, with some sort of suffix for the user. (eg. now a query would look like 'select * from table_ where attribute ='456'). In short, it's a difference between "select * from table where USER=" and "select * from table_USER".

    Read the article

  • ASP.NET MVC Inserting object and related object into 2 tables

    - by ile
    I have two tables: Users and UserOwners. Table UserOwners contains list of users that certain user created (list of child-users) - or to be more precise, it contains UserOwnerID and UserID fields. So, now I want to create a new user... in Controller I have something like this: var userOwner = accountRepository.GetUser(User.Identity.Name); var userOwnerID = userOwner.UserID; UserReference userReference = new UserReference(); userReference.UserOwnerID = userOwnerID; if (ModelState.IsValid) { try { //accountRepository.Add(user); //accountRepository.Save(); return View(); } catch { return View(); } } What is the easiest way to add new user to a table Users and matching UserOwner to UserOwners table. Is it suppose to be something like this? public void Add(User user) { db.Users.InsertOnSubmit(user); db.UserReferences.InsertOnSubmit(user.UserReference); } ...or I will have to pass two objects and after adding user I must read it's ID and than assign it to userReference object and add that object to DB? If so, how to read ID of the last object added? Thanks, Ile

    Read the article

  • Displaying data from linked tables in netbeans JTable

    - by Darc
    I have been writing in java for a few months now and have just started using netbeans. I have spent all day today trying to work out how to connect to an SQL database and display data from 2 tables (ie display the data from from a select statement with an inner join) in a JTable. I have tried using JPQL with the following statment SELECT j, cust.name FROM Job j JOIN j.jobnumber cust where the job table has a field called customer that references id in the customer table. This throws the exception: Caused by: Exception [TOPLINK-8029] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.EJBQLException Exception Description: Error compiling the query [SELECT j, cust.name FROM Job j JOIN j.jobnumber cust], line 1, column 11: invalid navigation expression [cust.name], cannot navigate expression [cust] of type [java.lang.Integer] inside a query. at oracle.toplink.essentials.exceptions.EJBQLException.invalidNavigation(EJBQLException.java:430) What am i doing wrong? Can anyone point me to some examples of how to make a linked table java application? I am still in the very early stages of development so a complete change is not out of the question if using a mysql database isnt the best way to go about things thanks

    Read the article

  • Best approach to cache Counts from SQL tables ?

    - by pixel3cs
    I would like to develop a Forum from scratch, with special needs and customization. I would like to prepare my forum for intensive usage and wondering how to cache things like User posts count and User replies count. Having only three tables, tblForum, tblForumTopics, tblForumReplies, what is the best approach of cache the User topics and replies counts ? Think at a simple scenario: user press a link and open the Replies.aspx?id=x&page=y page, and start reading replies. On the HTTP Request, the server will run an SQL command wich will fetch all replies for that page, also "inner joining with tblForumReplies to find out the number of User replies for each user that replied." select tblForumReplies.*, tblFR.TotalReplies from tblForumReplies inner join ( select IdRepliedBy, count(*) as TotalReplies from tblForumReplies group by IdRepliedBy ) as tblFR on tblFR.IdRepliedBy = tblForumReplies.IdRepliedBy Unfortunately this approach is very cpu intensive, and I would like to see your ideas of how to cache things like table Counts. If counting replies for each user on insert/delete, and store it in a separate field, how to syncronize with manual data changing. Suppose I will manually delete Replies from SQL.

    Read the article

  • Insert Into Two SQL Tables From XML Maintaining Relationship

    - by Thx
    I am looking to insert records from xml into two different tables. For example <Root> <A> <AValue>1</AValue> <Children> <B> <BValue>2</BValue> </B> </Children> </A> </Root> Would insert a record into table A AID AValue # 1 also insert a record into table B BID AID BValue # #(Same as AID Above) 2 I have this DECLARE @idoc INT DECLARE @doc NVARCHAR(MAX) SET @doc = ' <Root> <A> <AValue>1</AValue> <Children> <B> <BValue>2</BValue> </B> </Children> </A> </Root> ' EXEC sp_xml_preparedocument @idoc OUTPUT, @doc CREATE TABLE #A ( AID INT IDENTITY(1, 1) , AValue INT ) INSERT INTO #A SELECT * FROM OPENXML (@idoc, '/Root/A',2) WITH (AValue INT ) CREATE TABLE #B ( BID INT IDENTITY(1, 1) , AID INT , BValue INT ) INSERT INTO #B SELECT * FROM OPENXML (@idoc, '/Root/A/Children/B',2) WITH ( AID INT, BValue INT ) SELECT * FROM #A SELECT * FROM #B DROP TABLE #A DROP TABLE #B Thanks!

    Read the article

  • Selecting rows with references across tables in SQLite 3

    - by ChristianK
    Hey there, I have a problem with a SQLite photo/album database. The database contains 3 tables: Albums id name hide -------------------------- 1 Holiday 2010 1 2 Day Trip 0 Photos id file ----------------- 1 photo1.jpg 2 photo2.jpg 3 photo3.jpg 4 photo4.jpg Relation (connects photos with albums) album photo ----------------- 1 1 1 2 2 3 2 1 A photo can be assigned to zero, one or several albums. Each album has a column 'hide' that indicates, whether the photos of this album should be ignored. I'm trying to find a SELECT query that returns all photos that are not assigned to an album + all the photos that are in albums which are not hidden (i.e. that have their 'hide' value set to 0). I came up with a query that selects photos in visible albums, but I don't know how to include the photos that are not assigned to an album. SELECT file FROM photos, albums, relation WHERE photos.id = relation.photo AND albums.id = relation.album AND albums.hide = 0 This query returns photo3.jpg and the required result would be photo3.jpg photo4.jpg because photo4.jpg is not assigned to album in the Relation table. Do you know how to solve this? Thank you very much for your help!

    Read the article

  • detection of 'flush tables with read lock' in php

    - by theduke0
    I would like to know from my application if a myisam table can accept writes (i.e. not locked). If an exception is thrown, everything is fine as I can catch this and log the failed statement to a file. However, if a 'flush tables with read lock' command has been issued (possibly for backup), the query I send will pretty much hang out forever. If one table is locked at a time, insert delayed works well. But when this global lock is applied, my query just waits. The query I run is an insert statement. If this statement fails or hangs, user experience is degraded. I need a way to send the query to the server and forget about it (pretty much). Does anyone have any suggestions on how to deal with this? -set a query timeout? -run asyncronous request and allow for the lock to expire while application continues? -fork my php process? Please let me know if I can provide and clarification or details.

    Read the article

  • Database (MySQL) structuring: pros and cons of multiple tables

    - by Gideon
    I am collecting data and storing it MySQL, for: 75 variables 55 countries Each year I have, at this stage since I am building this tool created a single table, of variables / countries (storing 1 year worth of data). Next year (and for several years after that) a new set of data will be input for each country. There are therefore 3 variables in controlling data returned to a user reviewing all collected data. The general form of any query would be: Show me these specifics variables, for these specific countries, for these specific years. (Show me average age and weight, for USA and Canada, for 2012 and 2009, for example) My question is, it seems that I have two options for arranging this data: -Multiple tables where I create a table of country / variable for each year data is collected - Single table and simply add a column (field) for the year that data relates to. As far as I can tell I could make these database calls with either sructure, but is one more powerful / efficient / quicker, and why? Thanks for your consideration. It's a PDO / PHP interface if that is relevent.

    Read the article

  • How grouping and totaling are done into three tables using JOIN

    - by text
    Here are my tables respondents: field sample value respondentid : 1 age : 2 gender : male survey_questions: id : 1 question : Q1 answer : sample answer answers: respondentid : 1 question : Q1 answer : 1 --id of survey question I want to display all respondents who answered the certain survey, display all answers and total all the answer and group them according to the age bracket. I tried using this query: $sql = "SELECT res.Age, res.Gender, answer.id, answer.respondentid, SUM(CASE WHEN res.Gender='Male' THEN 1 else 0 END) AS males, SUM(CASE WHEN res.Gender='Female' THEN 1 else 0 END) AS females, CASE WHEN res.Age < 1 THEN 'age1' WHEN res.Age BETWEEN 1 AND 4 THEN 'age2' WHEN res.Age BETWEEN 4 AND 9 THEN 'age3' WHEN res.Age BETWEEN 10 AND 14 THEN 'age4' WHEN res.Age BETWEEN 15 AND 19 THEN 'age5' WHEN res.Age BETWEEN 20 AND 29 THEN 'age6' WHEN res.Age BETWEEN 30 AND 39 THEN 'age7' WHEN res.Age BETWEEN 40 AND 49 THEN 'age8' ELSE 'age9' END AS ageband FROM Respondents AS res INNER JOIN Answers as answer ON answer.respondentid=res.respondentid INNER JOIN Questions as question ON answer.Answer=question.id WHERE answer.Question='Q1' GROUP BY ageband ORDER BY res.Age ASC"; I was able to get the data but the listing of all answers are not present. What's wrong with my query. I want to produce something like this: ex: # of Respondents is 3 ages: 2,3 and 6 Question: what are your favorite subjects? Ages 1-4: subject 1: 1 subject 2: 2 subject 3: 2 total respondents for ages 1-4 : 2 Ages 5-10: subject 1: 1 subject 2: 1 subject 3: 0 total respondents for ages 5-10 : 1

    Read the article

  • SELECT Statement without duplicate rows on the multiple join tables

    - by theBo
    I have 4 tables built with JOINS and I would like to SELECT DISTINCT rows on the setsTbl.s_id so they always show regardless if there's relational data against them or not!. This is what I have at present which displays the data but doesn't display all of but not the entire distinct row! SELECT setsTbl.s_id, setsTbl.setName, userProfilesTbl.no + ' ' + userProfilesTbl.surname AS Name, trainingTbl.t_date, userAssessmentTbl.o_id FROM userProfilesTbl LEFT OUTER JOIN userAssessmentTbl ON userProfilesTbl.UserId = userAssessmentTbl.UserId FULL OUTER JOIN trainingTbl ON userAssessmentTbl.tt_id = trainingTbl.tt_id RIGHT OUTER JOIN setsTbl ON trainingTbl.s_id = setsTbl.s_id WHERE (userProfilesTbl.st_id=@st_id AND userProfilesTbl.sh_id=@sh_id) AND (DATEPART(yyyy,t_date) = @y_date ) OR (userAssessmentTbl.o_id IS NULL) ORDER BY setName ASC, t_date ASC With this statement I get some of the rows (the ones with data against them) but as stated the s_id field does not return distinct. This following inner select statement works in part when used in SQL Query analyzer and returns pretty much the data i require s_id setName Name o_id ----- ----- ----- ------ 1 100 Barnes 2 2 100 Beardsley 3 3 101 Aldridge 1 4 102 Molby 2 5 102 Whelan 3 but not when used outside of that environment. select * from ( SELECT userProfilesTbl.serviceNo + ' ' + userProfilesTbl.surname AS Name, userProfilesTbl.st_id, userProfilesTbl.sh_id, userAssessmentTbl.o_id, setsTbl.s_id, setsTbl.setName, row_number() over ( partition by setsTbl.s_id order by setsTbl.s_id ) r FROM userProfilesTbl LEFT OUTER JOIN userAssessmentTbl ON userProfilesTbl.UserId = userAssessmentTbl.UserId FULL OUTER JOIN trainingTbl ON userAssessmentTbl.tt_id = trainingTbl.tt_id RIGHT OUTER JOIN setsTbl ON trainingTbl.s_id = setsTbl.s_id ) x where x.r = 1 Not receiving any errors just not displaying the data?

    Read the article

  • Database tables with dynamic information

    - by Tim Fennis
    I've googled this and found that it's almost impossible to create a database with dynamic collumns. I'll explain my problem first. I am making a webshop for a customer. It has multiple computer products for sale. CPU's HDD's RAM ect. All these products have different properties, a CPU has an FSB, RAM has a CAS latency. But this is very inconvenient because my orders table needs foreign keys to different tables which is impossible. An other option is to store all the product specific information in a varchar or blob field and let PHP figure it out. The problem with this solution is that the website needs a PC builder. A step-by-step guide to building your PC. So for instance if a customer decides he wants a new "i7 920" or whatever i want to be able to sellect all motherboards for socket 1366, which is impossible because all the data is stored in one field. I know it's possible to select all motherboards form the DB and let PHP figure out which ones are for socket 1366 but i was wondering, is there a better solution?

    Read the article

  • Joining tables, if percentage is above certain value

    - by CluelessGerman
    My question is similar to this one: Compare rows and get percentage However, little different. I adapted my question to the other post. I got 2 tables. First table: user_id | post_id 1 1 1 2 1 3 2 12 2 15 And second table: post_id | rating 1 1 1 2 1 3 2 1 2 5 3 null 3 1 3 4 12 4 15 1 So now I would like to count the rating for each post, in the second table. If the rating has more than, lets say, 50% positive ratings than I want to get the post_id and going it to the post_id from table one and add 1 to the user_id. At the end it would return the user_id with the number of positive posts. The result for above table would be: user_id | helpfulPosts 1 2 2 1 The post with post_id 1 and 3 have positive rating, because more than 50% have ratings of 1-3. The post with id = 2 is not positive, because the rating is exactly 50%. How would I achieve this? For clarification: It's a mysql rdbm and a positive post, is one where the number of rating_ids with 1, 2 and 3 are more than half of the overall rating. Basically the same thing, from the other thread I posted above.

    Read the article

  • How to first get different related values from diferent SQL tables (PHP)

    - by Ole Jak
    I am triig to fill options list. I have 2 tables USERS and STREAMS I vant to get all streams and get names of users assigned to that streams. Users consists of username and id Streams consists of id, userID, streamID I try such code: <?php global $connection; $query = "SELECT * FROM streams "; $streams_set = mysql_query($query, $connection); confirm_query($streams_set); $streams_count = mysql_num_rows($streams_set); while ($row = mysql_fetch_array($streams_set)){ $userid = $row['userID']; global $connection; $query2 = "SELECT email, username "; $query2 .= "FROM users "; $query2 .= "WHERE id = '{$userid}' "; $qs = mysql_query($query2, $connection); confirm_query($qs); $found_user = mysql_fetch_array($qs); echo ' <option value="'.$row['streamID'].'">'.$row['userID'].$found_user.'</option> '; } ?> But it does not return USER names from DB=( So what shall I do to this code to see usernames as "options" text?

    Read the article

  • Auto-creating a "link" table between 2 main tables (ex table EmployeeProject from Employee and Project tables)

    - by user573382
    Hello! I have these 2 tables, Medication containing: IDMedication, IDCategory, Name, and Supplier, containing: IDSupplier, Name. I want to automatically create a relationship table, MedicationSupplier, containing: IDMedication and IDSupplier as keys, Price, and Quantity. My idea was to have a main page where i request the following data: (Medication)Name, IDCAtegory, (Supplier)Name, Price, Quantity. I'm not sure if i'm doing the right thing here. So this is what i'm receiveing in the .php where i do the insert: $Denumire=$_POST['Denumire']; //Medication Name $IDCategorie=$_POST['IDCategorie']; //IDCategory $Nume=$_POST['Nume']; //Supplier Name $Pret=$_POST['Pret']; //Price $Stoc=$_POST['Stoc']; //Quantity And this is my insert: $q_produse = "INSERT INTO produse VALUES ('','$IDCategorie','$Denumire')"; $q_prodfurniz = "INSERT INTO produsfurnizor VALUES ('','$IDFurnizor','$Pret','$Stoc')"; mysql_query($q_produse) or die($error); mysql_query($q_prodfurniz) or die($error); mysql_close(); My main problem at the moment is that i don't know how to insert IDMedication in the relationship table. Any help / suggestions of improving my code would be greatly appreciated. Thanks!

    Read the article

  • Multiple tables\objects in one nHibernate mapping

    - by Morrislgn
    Hi Folks I am trying to create an nHibernate mapping for a class structure like so: class UserDetails{ Guid id; User user; Role role; public User UserInfo{ get;set; } public Role UserRoles{ get;set; } public Guid ID{ Get; set; } } class User{ string name; int id; public string Name{ get;set; } public int ID{ get;set; } } class Role{ string roleName; string roleDesc; int roleId; public string RoleName{ get;set; } public string RoleDesc{ get;set; } public int RoleID{ get;set; } } The underlying DB structure is similar to the tables, but there is a linking table which links user and role using their respective IDs: UserRoleLinkTable[ identity User_Role_ID (pk) userID (FK to User table) roleid (FK to Role table) ] After playing about with nHibernate this is similar to what I want to try and achieve (but it doesnt work!): <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Admin" namespace="Admin" > <class name="UserDetails" lazy="false" table="USER"> <id name="ID"> <generator class="guid"></generator> </id> <one-to-one name="UserInfo" class="User" lazy="false" cascade="none"/> <bag name="UserRoles" inverse="false" table="Role" lazy="false" cascade="none" > <key column="Role" /> <many-to-many class="Role" column="ROLE_ID" /> </bag> </class> </hibernate-mapping> I have mappings\entities which appear to work for Role and User (used in other aspects of the project) objects but how do I pull this information into one UserDetails class? The point of the user details to be able to return all this information together as one object. Is it possible to create (for want of a better description) a container using an nHibernate mapping and map the data that way? Hopefully there is enough info to help work this out - thanks in advance for all help given! Cheers, Morris

    Read the article

  • T-SQL Script to Delete All The Relationships Between A Bunch Of Tables in a Schema and Other Bunch i

    - by Galilyou
    Guys, I have a set of tables (say Account, Customer) in a schema (say dbo) and I have some other tables (say Order, OrderItem) in another schema (say inventory). There's a relationship between the Order table and the Customer table. I want to delete all the relationships between the tables in the first schema (dbo) and the tables in the second schema (inventory), without deleting the relationships between tables inside the same schema. Is that possible? Any help appreciated.

    Read the article

  • CSS Child selectors in IE7 tables

    - by John
    I'm trying to use the CSS child selector in IE7, and it doesn't seem to work. I have nested tables. My outer table has a class name "mytable", and I want the td's of the outer table to show borders. I don't want the inner table td's to have borders. I think I should be able to have CSS that looks like this: .mytable { border-style: solid } .mytable>tr>td { border-style: solid } But the second line seems to have no effect. If I change the second line to make it less specific, it applies to all the td's - I see too many borders. td { border-style: solid } So I think it really is just an issue with the selectors. Pages like this suggest that IE7 should be able to do what I want. Am I doing something silly? Here's the whole HTML file: <html> <head> <style type="text/css"> .mytable { border-style: solid; border-collapse: collapse;} td { border-style: solid; } </style> </head> <body> <table class="mytable"> <tr> <td>Outer top-left</td> <td>Outer top-right</td> </tr> <tr> <td>Outer bottom-left</td> <td> <table> <tr> <td>Inner top-left</td> <td>Inner top-right</td> </tr> <tr> <td>Inner bottom-left</td> <td>Inner bottom-right</td> </tr> <table> </td> </tr> <table> </body> </html>

    Read the article

  • Using Hibernate to do a query involving two tables

    - by Nathan Spears
    I'm inexperienced with sql in general, so using Hibernate is like looking for an answer before I know exactly what the question is. Please feel free to correct any misunderstandings I have. I am on a project where I have to use Hibernate. Most of what I am doing is pretty basic and I could copy and modify. Now I would like to do something different and I'm not sure how configuration and syntax need to come together. Let's say I have two tables. Table A has two (relevant) columns, user GUID and manager GUID. Obviously managers can have more than one user under them, so queries on manager can return more than one row. Additionally, a manager can be managing the same user on multiple projects, so the same user can be returned multiple times for the same manager query. Table B has two columns, user GUID and user full name. One-to-one mapping there. I want to do a query on manager GUID from Table A, group them by unique User GUID (so the same User isn't in the results twice), then return those users' full names from Table B. I could do this in sql without too much trouble but I want to use Hibernate so I don't have to parse the sql results by hand. That's one of the points of using Hibernate, isn't it? Right now I have Hibernate mappings that map each column in Table A to a field (well the get/set methods I guess) in a DAO object that I wrote just to hold that Table's data. I could also use the Hibernate DAOs I have to access each table separately and do each of the things I mentioned above in separate steps, but that would be less efficient (I assume) that doing one query. I wrote a Service object to hold the data that gets returned from the query (my example is simplified - I'm going to keep some other data from Table A and get multiple columns from Table B) but I'm at a loss for how to write a DAO that can do the join, or use the DAOs I have to do the join. FYI, here is a sample of my hibernate config file (simplified to match my example): <hibernate-mapping package="com.my.dao"> <class name="TableA" table="table_a"> <id name="pkIndex" column="pk_index" /> <property name="userGuid" column="user_guid" /> <property name="managerGuid" column="manager_guid" /> </class> </hibernate-mapping> So then I have a DAOImplementation class that does queries and returns lists like public List<TableA> findByHQL(String hql, Map<String, String> params) etc. I'm not sure how "best practice" that is either.

    Read the article

  • Yii - Custom GridView with Multiple Tables

    - by savinger
    So, I've extended GridView to include an Advanced Search feature tailored to the needs of my organization. Filter - lets you show/hide columns in the table, and you can also reorder columns by dragging the little drag icon to the left of each item. Sort - Allows for the selection of multiple columns, specify Ascending or Descending. Search - Select your column and insert search parameters. Operators tailored to data type of selected column. Version 1 works, albeit slowly. Basically, I had my hands in the inner workings of CGridView, where I snatch the results from the DataProvider and do the searching and sorting in PHP before rendering the table contents. Now writing Version 2, where I aim to focus on clever CDbCriteria creation, allowing MySQL to do the heavy lifting so it will run quicker. The implementation is trivial when dealing with a single database table. The difficulty arises when I'm dealing with 2 or more tables... For example, if the user intends to search on a field that is a STAT relation, I need that relation to be present in my query. Here's the question. How do I assure that Yii includes all with relations in my query so that I include comparisons? I've included all my relations with my criteria in the model's search function and I've tried CDbCriteria's together ... public function search() { $criteria=new CDbCriteria; $criteria->compare('id', $this->id); $criteria->compare( ... ... $criteria->with = array('relation1','relation2','relation3'); $criteria->together = true; return new CActiveDataProvider( get_class($this), array( 'criteria'=>$criteria, 'pagination' => array('pageSize' => 50) ));} But I still get errors like this... CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 't.relation3' in 'where clause'. The SQL statement executed was: SELECT COUNT(DISTINCT `t`.`id`) FROM `table` `t` LEFT OUTER JOIN `relation_table` `relation0` ON (`t`.`id`=`relation0`.`id`) LEFT OUTER JOIN `relation_table` `relation1` ON (`t`.`id`=`relation1`.`id`) WHERE (`t`.`relation3` < 1234567890) Where relation0 and relation1 are BELONGS_TO relations, but any STAT relations are missing. Furthermore, why is the query a SELECT COUNT(DISTINCT 't'.'id') ?

    Read the article

  • why cant I more than two values from 3 different tables in one query

    - by zurna
    This is strange. In the news details page, I want to take a few different values from different tables with one query. However, for some strange reason, I only get two values back. So the outcome is like: <rows> <row id="4"> <FullName>Efe Tuncel</FullName> <CategoryName/> <Title>Runway Report</Title> <ShortDesc/> <Desc></Desc> <Date/> </row> </rows> If I disable fullname, then I get shortdesc but not others. Same things happens with others. NewsID = Request.QueryString("NEWSID") SQL = "SELECT N.NewsID, N.MembersID, N.CategoriesID, N.ImagesID, N.NewsTitle, N.NewsShortDesc, N.NewsDesc, N.NewsActive, N.NewsDateEntered, C.CategoriesID, C.CategoriesName, M.MembersID, M.MembersFullName" SQL = SQL & " FROM News N, Categories C, Members M" SQL = SQL & " WHERE N.NewsID = "& NewsID &" AND N.NewsActive = 1 AND N.MembersID = M.MembersID AND N.CategoriesID = C.CategoriesID" Set objViewNews = objConn.Execute(SQL) With Response .Write "<?xml version='1.0' encoding='windows-1254' ?>" .Write "<rows>" End With With Response .Write "<row id='"& objViewNews("NewsID") &"'>" .Write "<FullName>"& objViewNews("MembersFullName") &"</FullName>" .Write "<CategoryName>"& objViewNews("CategoriesName") &"</CategoryName>" .Write "<Title>"& objViewNews("NewsTitle") &"</Title>" .Write "<ShortDesc>"& objViewNews("NewsShortDesc") &"</ShortDesc>" .Write "<Desc><![CDATA["& objViewNews("NewsDesc") &"]]></Desc>" .Write "<Date>"& objViewNews("NewsDateEntered") &"</Date>" .Write "</row>" End With With Response .Write "</rows>" End With objViewNews.Close Set objViewNews = Nothing

    Read the article

  • Copying 6000 tables and data from sqlserver to oracle ==> fastest method?

    - by nazer555
    i need to copy the tables and data (about 5 yrs data, 6200 tables) stored in sqlserver, i am using datastage and odbc connection to connect and datstage automatically creates the table with data, but its taking 2-3 hours per table as tables are very large(0.5 gig, 300+columns and about 400k rows). How can i achieve this the fastes as at this rate i am able to only copy 5 tables per day but within 30 days i need move over these 6000 tables.

    Read the article

< Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >